test

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TemporaryEnvVars added in v0.0.2

func TemporaryEnvVars(keyValues ...string) func()

func TemporaryUnsetEnvVars added in v0.0.9

func TemporaryUnsetEnvVars(keys ...string) func()

Types

type Cmd

type Cmd cobra.Command

Cmd is an alias for cobra.Command to build fluent API for building commands in tests.

func Run

func Run(command *cobra.Command) *Cmd

Run will run actual command.

func ValidateArgumentsOf

func ValidateArgumentsOf(command *cobra.Command) *Cmd

ValidateArgumentsOf will not run actual command but let the initialization and validation happen.

func (*Cmd) Passing

func (command *Cmd) Passing(args ...string) (output string, err error)

Passing allows passing arguments to command under test.

type TestReporter

type TestReporter interface {
	Errorf(format string, args ...interface{})
}

TestReporter can be used to report test failures. It is satisfied by the standard library's *testing.T.

type TmpFileSystem added in v0.5.0

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

func NewTmpFileSystem added in v0.5.0

func NewTmpFileSystem(t TestReporter) TmpFileSystem

func (*TmpFileSystem) Cleanup added in v0.5.0

func (tmp *TmpFileSystem) Cleanup()

Cleanup removes all files in our test registry and calls `t.Errorf` if something goes wrong.

func (*TmpFileSystem) Dir added in v0.5.0

func (tmp *TmpFileSystem) Dir(dir string) string

Dir creates a temporary directory under os.TempDir() with a following pattern: os.TempDir()/[random-alphanumeric]/dir, where dir is a passed parameter which can be a relative path When dir is an absolute path and error is reported.

func (*TmpFileSystem) File added in v0.5.0

func (tmp *TmpFileSystem) File(filePath, content string) afero.File

File creates a specified file to use when testing if filePath is a full path it will just be created and cleaned up afterwards otherwise the file will be places under some random alphanumeric folder under temp directory.

type TmpPath

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

TmpPath lets you overwrite $PATH environment variable for the duration of tests.

func NewTmpPath

func NewTmpPath() *TmpPath

NewTmpPath creates new instance of TmpPath with stored original value assigned to $PATH environment variable.

func (*TmpPath) Restore

func (t *TmpPath) Restore()

Restore restores $PATH to its original value from before creation of TmpPath instance.

func (*TmpPath) SetPath

func (t *TmpPath) SetPath(paths ...string)

SetPath defines $PATH value.

Directories

Path Synopsis
cmd
test-service
Code generated for package main by go-bindata DO NOT EDIT.
Code generated for package main by go-bindata DO NOT EDIT.
Test double that echoes passed arguments and flags.
Test double that echoes passed arguments and flags.

Jump to

Keyboard shortcuts

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