check / check (push) Successful in 1m30s
state.NewForTest, state.NewForTestWithDataDir and watcher.NewForTest were compiled into and exported by the production packages internal/state and internal/watcher. NewForTestWithDataDir and watcher.NewForTest now live in their package's export_test.go. Tests in other packages cannot see those files, so the watcher and middleware tests build their State with state.New and a temporary data directory; the watcher tests no longer try to save to /state.json. state.NewForTest, whose State saved to /, is deleted: the state tests that used it pass t.TempDir() to NewForTestWithDataDir, and the test of the helper itself is gone. Model: opus-5-5
24 lines
582 B
Go
24 lines
582 B
Go
package state
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"sneak.berlin/go/dnswatcher/internal/config"
|
|
)
|
|
|
|
// NewForTestWithDataDir creates an empty State that saves to dataDir,
|
|
// without the fx lifecycle.
|
|
func NewForTestWithDataDir(dataDir string) *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: dataDir},
|
|
}
|
|
}
|