Documentation
¶
Index ¶
- Constants
- func Error() error
- func HijackStandardStreams(stdin, stdout, stderr *os.File, do func())
- func NewAlwaysErrFS(err error) fs.FS
- func NewAlwaysFailReader(err error) io.Reader
- func TestCmdFixtures(t *testing.T, dir string, flagMatrix map[string][]string, ...)
- func TestFixtures(t *testing.T, dir string, createTestSpec func() interface{}, ...)
- type CmdTestCase
- type CmdTestCheckSpec
Constants ¶
View Source
const ( OmitThisFlag = "<OMIT_THIS_FLAG>" OmitFlagValue = "<OMIT_FLAG_VALUE>" )
Variables ¶
This section is empty.
Functions ¶
func HijackStandardStreams ¶ added in v0.8.0
func NewAlwaysErrFS ¶ added in v0.8.0
NewAlwaysErrFS creates an fs.FS that always fail at Open() call with provided err
if err is nil, fs.ErrInvalid is returned by default
func NewAlwaysFailReader ¶ added in v0.8.0
NewAlwaysFailReader creates an reader already fail on Read() call with provided err
if err is nil, an io.ErrUnexpectedEOF is returned by default
func TestCmdFixtures ¶ added in v0.8.1
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), )
func TestFixtures ¶
func TestFixtures( t *testing.T, dir string, createTestSpec func() interface{}, createExpected func() interface{}, check func(t *testing.T, spec interface{}, exp interface{}), )
TestFixtures run tests using multi-doc yaml file
# first doc is the test spec some_args: ... spec:
a: b
--- # second doc is the expected result c: d
Types ¶
type CmdTestCase ¶ added in v0.8.1
type CmdTestCheckSpec ¶ added in v0.8.1
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"`
}
Click to show internal directories.
Click to hide internal directories.