testutils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertStdOutAndStdErr

func AssertStdOutAndStdErr(t *testing.T, testdata *TestData, ttName string, outWriter, errWriter *bytes.Buffer)

func RunTestCommand_Execute

func RunTestCommand_Execute(
	t *testing.T,
	tests []TestCaseExecute,
	testdata *TestData,
	newCmd Factory,
	customAssertion CustomAssertion[TestCaseExecute],
)

func RunTestCommand_Parse

func RunTestCommand_Parse(
	t *testing.T,
	tests []TestCaseParse,
	testdata *TestData,
	newCmd Factory,
	customAssertion CustomAssertion[TestCaseParse],
)

func RunTestCommand_Usage

func RunTestCommand_Usage(
	t *testing.T,
	tests []TestCaseUsage,
	testdata *TestData,
	newCmd Factory,
	customAssertion CustomAssertion[TestCaseUsage],
)

Types

type CustomAssertion

type CustomAssertion[T any] func(
	t *testing.T,
	tt T,
	update bool,
	cmd mycmd.Command,
	actual []any,
)

type Factory

type Factory func() mycmd.Command

type SetupFunc

type SetupFunc[T any] func(t *testing.T, tt T)

type TestCaseExecute

type TestCaseExecute struct {
	Name  string
	Args  []string
	Want  int
	Setup SetupFunc[TestCaseExecute]
}

type TestCaseParse

type TestCaseParse struct {
	Name      string
	Args      []string
	WantError bool
	Setup     SetupFunc[TestCaseParse]
}

type TestCaseUsage

type TestCaseUsage struct {
	Name  string
	Setup SetupFunc[TestCaseUsage]
}

type TestData

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

func NewTestData

func NewTestData(t *testing.T, name string) *TestData

func (*TestData) CompareWithGolden

func (d *TestData) CompareWithGolden(t *testing.T, update bool, goldenFileName string, actual []byte)

func (*TestData) FileName

func (d *TestData) FileName(t *testing.T, elm ...string) string

func (*TestData) ReadFile

func (d *TestData) ReadFile(t *testing.T, filename string) []byte

func (*TestData) RootDir

func (d *TestData) RootDir(t *testing.T) string

func (*TestData) TempDirInTestdata

func (d *TestData) TempDirInTestdata(t *testing.T, suffix string) string

TempDirInTestdata makes temp directory for test. If you need fixed name temp directory, use this method instead of testing.T.TempDir().

func (*TestData) WriteFile

func (d *TestData) WriteFile(t *testing.T, filename string, data []byte)

Jump to

Keyboard shortcuts

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