option

package
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 3 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.

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) NewCmd

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

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

Jump to

Keyboard shortcuts

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