cmdtesthelper

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OmitThisFlag  = "<OMIT_THIS_FLAG>"
	OmitFlagValue = "<OMIT_FLAG_VALUE>"
)

Variables

This section is empty.

Functions

func TestCmdFixtures

func TestCmdFixtures(t *testing.T,
	dir string,
	flagMatrix map[string][]string,
	genNewSpec func(
		flagSets [][]string, baseSpec *CmdTestCase, baseCheck *CmdTestCheckSpec,
	) (*CmdTestCase, *CmdTestCheckSpec),
	prepareRun func(flags []string) (checkFlags func() error, runCmd func() error, _ error),
)

Types

type CmdTestCase

type CmdTestCase struct {
	rs.BaseField

	// Flags is the command line flags to cmd, including positional args
	Flags []string `yaml:"flags"`

	// Stdin is the input to cmd stdin
	Stdin string `yaml:"stdin"`
}

type CmdTestCheckSpec

type CmdTestCheckSpec struct {
	rs.BaseField

	// BadFlags expects optoins and/or args are invalid
	BadFlags bool `yaml:"bad_flags"`

	// BadCmd expects cmd run error
	//
	// after parsing all flags and before checking output
	BadCmd bool `yaml:"bad_cmd"`

	// Stdout is the expected output to stdout
	Stdout string `yaml:"stdout"`

	// Stderr is the expected output to stderr
	Stderr string `yaml:"stderr"`
}

Jump to

Keyboard shortcuts

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