Documentation
¶
Overview ¶
Package testutil provides shared test helpers for the go-tool-base module.
Index ¶
- func FileStoreFromYAML(t *testing.T, yaml string, opts ...config.StoreOption) *config.Store
- func FileViewFromYAML(t *testing.T, yaml string, opts ...config.StoreOption) *config.View
- func SkipIfNotIntegration(t *testing.T, tags ...string)
- func StoreFromYAML(t *testing.T, yaml string, opts ...config.StoreOption) *config.Store
- func ViewFromYAML(t *testing.T, yaml string, opts ...config.StoreOption) *config.View
- type MutableSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileStoreFromYAML ¶ added in v0.32.0
FileStoreFromYAML builds a store whose YAML document loads as a FILE layer (a writable config file on a MemMapFs) — for tests that depend on user-authored provenance or a writable Apply target, which a reader layer deliberately is not.
func FileViewFromYAML ¶ added in v0.32.0
FileViewFromYAML pins a view over a file-layer-backed YAML document.
func SkipIfNotIntegration ¶
SkipIfNotIntegration skips the current test unless integration tests are enabled. Tests are enabled when:
- INT_TEST is set to any non-empty value (runs all integration tests), OR
- INT_TEST_<TAG> is set for any of the provided tags (targeted runs).
Tags are matched case-insensitively against INT_TEST_<TAG> environment variables, allowing targeted execution of specific test groups:
testutil.SkipIfNotIntegration(t, "vcs") // runs if INT_TEST=1 OR INT_TEST_VCS=1 testutil.SkipIfNotIntegration(t, "setup") // runs if INT_TEST=1 OR INT_TEST_SETUP=1 testutil.SkipIfNotIntegration(t) // runs only if INT_TEST=1
func StoreFromYAML ¶ added in v0.32.0
StoreFromYAML builds a config store over the given YAML document, with any further options (e.g. config.WithEnv) layered above it in precedence order.
func ViewFromYAML ¶ added in v0.32.0
ViewFromYAML pins a view over the given YAML document.
Types ¶
type MutableSource ¶ added in v0.32.0
type MutableSource struct {
// contains filtered or unexported fields
}
MutableSource is a config backend whose content a test can replace before calling Store.Reload — the reload idiom the config module's own tests use.
func MutableStoreFromYAML ¶ added in v0.32.0
MutableStoreFromYAML builds a store over content the test can change with MutableSource.Set followed by Store.Reload.
func (*MutableSource) Capabilities ¶ added in v0.32.0
func (m *MutableSource) Capabilities() config.Capabilities
Capabilities reports the source as read-only.
func (*MutableSource) ID ¶ added in v0.32.0
func (m *MutableSource) ID() string
ID identifies the backend; it is constant so a reload replaces the layer.
func (*MutableSource) Load ¶ added in v0.32.0
Load satisfies config.Backend over the current content.
func (*MutableSource) Set ¶ added in v0.32.0
func (m *MutableSource) Set(yaml string)
Set replaces the backend's content; call Store.Reload to publish it.