option

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package option customizes how tests are run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Modifier

type Modifier interface {
	// contains filtered or unexported methods
}

Modifier modifies an Option.

It is not intended to be implemented by code outside this package. It is created to provide the flexibility to pass more things to option.New in the future without the need to update its signature.

func Env

func Env(env []string) Modifier

Env specifies the environment variables to be used during testing. It has the same format as Cmd.Env in os/exec.

func WithNerdctlVersion added in v0.9.1

func WithNerdctlVersion(version string) Modifier

WithNerdctlVersion denotes the underlying nerdctl version.

This is useful for tests whose expectations change based on the underlying nerdctl version.

func WithNoEnvironmentVariablePassthrough added in v0.9.0

func WithNoEnvironmentVariablePassthrough() Modifier

WithNoEnvironmentVariablePassthrough denotes the option does not support environment variable passthrough.

This is useful for disabling tests that require this feature.

type Option

type Option struct {
	// contains filtered or unexported fields
}

Option customizes how tests are run.

If a testing function needs special customizations other than the ones specified in Option, we can use composition to extend it. For example, to test login functionality, we may create a struct named LoginOption that embeds Option and contains additional fields like Username and Password.

func New

func New(subject []string, modifiers ...Modifier) (*Option, error)

New does some sanity checks on the arguments before initializing an Option.

subject specifies the subject to be tested. It is intentionally not designed as an (optional) Modifier because it must contain at least one element. Essentially it is used as a prefix when invoking all the binaries during testing.

For example, if subject is ["foo", "bar"], then to test pulling a image, the command name would be "foo", and the command args would be something like ["bar", "pull", "alpine"].

func (*Option) DeleteEnv added in v0.7.23

func (o *Option) DeleteEnv(envKey string)

DeleteEnv deletes the environment variable for the key name of the input.

func (*Option) IsNerdctlV1 added in v0.9.1

func (o *Option) IsNerdctlV1() bool

IsNerdctlV1 is used by tests to check if the option supports [feature.nerdctlVersion] == nerdctl1xx.

func (*Option) IsNerdctlV2 added in v0.9.1

func (o *Option) IsNerdctlV2() bool

IsNerdctlV2 is used by tests to check if the option supports [feature.nerdctlVersion] == nerdctl2xx.

func (*Option) NewCmd

func (o *Option) NewCmd(args ...string) *exec.Cmd

NewCmd creates a command using the stored option and the provided args.

func (*Option) SupportsEnvVarPassthrough added in v0.9.0

func (o *Option) SupportsEnvVarPassthrough() bool

SupportsEnvVarPassthrough is used by tests to check if the option supports [feature.environmentVariablePassthrough].

func (*Option) UpdateEnv added in v0.7.23

func (o *Option) UpdateEnv(envKey, envValue string)

UpdateEnv updates the environment variable for the key name of the input.

Jump to

Keyboard shortcuts

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