testutil

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareChanges

func CompareChanges(t *testing.T, want, got file.Changes)

CompareChanges compares the expected file changes to the ones received.

func CompareGoldenFile

func CompareGoldenFile(t *testing.T, tc *TestCase)

CompareGoldenFile verifies that the output of an operation matches the expected output.

func CompareSourcePath

func CompareSourcePath(t *testing.T, want []string, changes file.Changes)

CompareSourcePath compares the expected source paths to the actual source paths.

func CompareTargetPath

func CompareTargetPath(t *testing.T, want []string, changes file.Changes)

CompareTargetPath verifies that the renaming target matches expectations.

func GetConfig

func GetConfig(t *testing.T, tc *TestCase, testDir string) *config.Config

GetConfig constructs the app configuration from command-line arguments.

func ProcessTestCaseChanges

func ProcessTestCaseChanges(t *testing.T, cases []TestCase)

func RunTestCase

func RunTestCase(
	t *testing.T,
	tc *TestCase,
	runFunc func(t *testing.T, tc *TestCase),
)

func SetupFileSystem

func SetupFileSystem(
	tb testing.TB,
	testName string,
	fileSystem []string,
) string

SetupFileSystem creates all required files and folders for the tests and returns the absolute path to the root directory.

func UpdateBaseDir

func UpdateBaseDir(expected []string, testDir string)

UpdateBaseDir adds the testDir to each expected path for easy comparison.

func UpdateFileChanges

func UpdateFileChanges(files file.Changes)

Types

type TestCase

type TestCase struct {
	Error            error                                                `json:"error"`
	SetEnv           map[string]string                                    `json:"env"`
	SetupFunc        func(t *testing.T, testDir string) (teardown func()) `json:"-"`
	StdoutGoldenFile string                                               `json:"stdout_golden_file"`
	DefaultOpts      string                                               `json:"default_opts"`
	Name             string                                               `json:"name"`
	StderrGoldenFile string                                               `json:"stderr_golden_file"`
	SnapShot         struct {
		Stdout []byte
		Stderr []byte
	} `json:"-"`
	Args             []string     `json:"args"`
	PathArgs         []string     `json:"path_args"`
	Changes          file.Changes `json:"changes"`
	Want             []string     `json:"want"`
	ConflictDetected bool         `json:"conflict_detected"`
	PipeOutput       bool         `json:"pipe_output"`
}

TestCase represents a unique test case.

Jump to

Keyboard shortcuts

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