testutils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTestProcessResponse

func AddTestProcessResponse(response TestProcessResponse)

func CheckLogEntries

func CheckLogEntries(t *testing.T, hook *test.Hook, message string)

CheckLogEntries checks the latest logged entry if the message begin with the given prefix. If the prefix is "" then it expects that no log messages were written.

func CheckLogEntry

func CheckLogEntry(t *testing.T, hook *test.Hook, prefix string)

CheckLogEntry checks the latest logged entry if the message begin with the given prefix. If the prefix is "" then it expects that no log messages were written.

func ClearTestProcessResponse

func ClearTestProcessResponse()

func ExtractMockedCommandAndArgs

func ExtractMockedCommandAndArgs() (string, []string)

Extract the command name and arguments of the mocked exec call using FakeExecCommand()

func FakeExecCommand

func FakeExecCommand(command string, args ...string) *exec.Cmd

This command fakes the exec command. This should be only used in Tests.

func MockInitSudo

func MockInitSudo()

MockInitSudo adds the TestProcessResponse for `sh.initSudo` to `testutils.testProcessResponses`.

func MockWithStdOut

func MockWithStdOut(stdOut string, returnStatus int, cmd string, args ...string)

func MockWithoutResponse

func MockWithoutResponse(returnStatus int, cmd string, args ...string)

MockWithoutResponse adds a simple TestProcessResponse.

func SetTestProcessResponse

func SetTestProcessResponse(response TestProcessResponse)

func SetTestProcessResponses

func SetTestProcessResponses(responses []TestProcessResponse)

func StandardHelperProcess

func StandardHelperProcess(_ *testing.T)

func StartCommandLineTest

func StartCommandLineTest()

StartCommandLineTest initializes everything that is needed for commandline tests.

func StopCommandLineTest

func StopCommandLineTest()

StopCommandLineTests reset the changes from StartCommandLineTest.

Types

type TestProcessResponse

type TestProcessResponse struct {
	Command        string
	Args           []string
	ResponseStatus int
	Stdout         string
	Stderr         string
	ExpectedStdin  string
	Delay          time.Duration
	// AltResponseStatus will be returned if stdin got something else as expected
	AltResponseStatus int
}

func FindTestProcessResponse

func FindTestProcessResponse(responses []TestProcessResponse, cmd string, args []string) *TestProcessResponse

Jump to

Keyboard shortcuts

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