Documentation
¶
Overview ¶
Package testenv contains test environment utilities
Index ¶
- Constants
- func CLIVersion(ctx context.Context) (string, error)
- func FetchState[S WithState](ctx context.Context) *S
- func HasState[S WithState](ctx context.Context) bool
- func NoColorOutput(ctx context.Context) bool
- func Persist(ctx context.Context) (bool, error)
- func Persisted(ctx context.Context) bool
- func Restored(ctx context.Context) bool
- func SetupState[S WithState](ctx context.Context, state **S) (context.Context, error)
- func TempDir(ctx context.Context) (context.Context, string)
- func TestContainersRequest(ctx context.Context, req testcontainers.ContainerRequest) testcontainers.ContainerRequest
- func Testing(ctx context.Context) *testing.T
- type Initializing
- type WithState
Constants ¶
const ( PersistStubEnvironment testEnv = iota // key to a bool flag telling if the environment is persisted RestoreStubEnvironment // key to a bool flag telling if the environment is restored NoColors // key to a bool flag telling if the colors should be used in output TestingT // key to the *testing.T instance in Context RekorImpl // key to a implementation of the Rekor interface, used to prevent import cycles Scenario // key to a the *godog.Scenario of the current scenario, used to prevent import cycles TestUtil // key to a test utility struct )
Keys we use to look up the state in the Context
Variables ¶
This section is empty.
Functions ¶
func CLIVersion ¶
CLIVersion returns the version of the CLI, useful for matching in snapshots
func FetchState ¶
FetchState fetches the state from the Context stored under S.Key()
func NoColorOutput ¶
NoColorOutput returns true if the output produced should not contain colors, which is useful when a terminal or medium can't interpret ANSI colors
func Persisted ¶
Persisted returns true if the test environment persists after the test has finished
func Restored ¶
Restored returns true if the test environment is restored from the last persisted environment
func SetupState ¶
SetupState initializes the given state S and stores it in Context under S.Key(), if invoked twice for the same S.Key() the state will be set to the existing value from Context. If the test environment is being restored, values from the persisted file will be loaded.
func TestContainersRequest ¶
func TestContainersRequest(ctx context.Context, req testcontainers.ContainerRequest) testcontainers.ContainerRequest
TestContainersRequest modifies the req to keep the container running after the test if PersistStubEnvironment is set to true in the ctx
Types ¶
type Initializing ¶
type Initializing interface {
Initialize()
}