testutil

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package testutil provides shared test helpers for the go-tool-base module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileStoreFromYAML added in v0.32.0

func FileStoreFromYAML(t *testing.T, yaml string, opts ...config.StoreOption) *config.Store

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

func FileViewFromYAML(t *testing.T, yaml string, opts ...config.StoreOption) *config.View

FileViewFromYAML pins a view over a file-layer-backed YAML document.

func SkipIfNotIntegration

func SkipIfNotIntegration(t *testing.T, tags ...string)

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

func StoreFromYAML(t *testing.T, yaml string, opts ...config.StoreOption) *config.Store

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

func ViewFromYAML(t *testing.T, yaml string, opts ...config.StoreOption) *config.View

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

func MutableStoreFromYAML(t *testing.T, yaml string) (*config.Store, *MutableSource)

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

func (m *MutableSource) Load(ctx context.Context, _ []config.Layer) ([]config.Layer, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL