test

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Files []string

Files keeps track of files that we've used so we can clean up.

Functions

func CleanUpTmpFiles

func CleanUpTmpFiles(t TestReporter)

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

func RunSpecWithJUnitReporter

func RunSpecWithJUnitReporter(t *testing.T, description string)

RunSpecWithJUnitReporter calls custom ginkgo junit reporter.

func TemporaryEnvVars added in v0.0.2

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

func TemporaryUnsetEnvVars added in v0.0.9

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

func TmpDir

func TmpDir(t TestReporter, dir string) string

TmpDir 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 TmpFile

func TmpFile(t TestReporter, filePath, content string) afero.File

TmpFile creates a specified file for us 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.

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 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