test: add watcher orchestrator tests with mock dependencies
Tests cover: first-run baseline, NS change detection, record change detection, port state changes, TLS expiry warnings, graceful shutdown, and NS failure/recovery scenarios.
This commit is contained in:
22
internal/state/state_test_helper.go
Normal file
22
internal/state/state_test_helper.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"sneak.berlin/go/dnswatcher/internal/config"
|
||||
)
|
||||
|
||||
// NewForTest creates a State for unit testing with no persistence.
|
||||
func NewForTest() *State {
|
||||
return &State{
|
||||
log: slog.Default(),
|
||||
snapshot: &Snapshot{
|
||||
Version: stateVersion,
|
||||
Domains: make(map[string]*DomainState),
|
||||
Hostnames: make(map[string]*HostnameState),
|
||||
Ports: make(map[string]*PortState),
|
||||
Certificates: make(map[string]*CertificateState),
|
||||
},
|
||||
config: &config.Config{DataDir: ""},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user