Documentation
¶
Overview ¶
Package testutil centralises test helpers shared across the fastconf module. It is an internal package so it cannot be imported by external code; sub-packages that need these helpers add:
import "github.com/fastabc/fastconf/internal/testutil"
Three categories of helpers are provided:
- File-system setup — WriteFile, TempConf
- Polling — WaitFor
- Provider stubs — FakeProvider
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TempConf ¶
TempConf creates a temporary directory, populates it with files whose paths (relative to the temp root) and contents are given by the files map, and returns the temp root. The caller may use t.TempDir()-based registration for cleanup — this function registers nothing itself.
Example:
root := testutil.TempConf(t, map[string]string{
"conf.d/base/00-base.yaml": "port: 8080\n",
"conf.d/overlays/prod/01-prod.yaml": "port: 443\n",
})
Types ¶
type FakeProvider ¶
type FakeProvider struct {
// LoadErr, if non-nil, is returned by Load instead of data.
LoadErr error
// contains filtered or unexported fields
}
FakeProvider is a stub contracts.Provider backed by a static map. Watch returns nil (no change notifications). Useful for unit tests that need a provider without spinning up a real remote source.
func NewFakeProvider ¶
func NewFakeProvider(name string, priority int, data map[string]any) *FakeProvider
NewFakeProvider constructs a FakeProvider with the given name, priority and static data.
func (*FakeProvider) Name ¶
func (f *FakeProvider) Name() string
func (*FakeProvider) Priority ¶
func (f *FakeProvider) Priority() int