testutil

package
v6.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: BSD-3-Clause Imports: 10 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 Command

func Command(t testing.TB, args ...string) *exec.Cmd

Command returns an exec.Cmd appropriate for testing the u-root command.

Command decides which executable to call based on environment variables: - EXECPATH="executable args" overrides any other test subject. - UROOT_TEST_BUILD=1 will force compiling the u-root command in question.

func IsExitCode

func IsExitCode(err error, exitCode int) error

IsExitCode takes err and checks whether it represents the given process exit code.

IsExitCode assumes that `err` is the return value of a successful call to exec.Cmd.Run/Output/CombinedOutput and hence an *exec.ExitError.

func Run

func Run(m *testing.M, mainFn func())

Run sets up necessary commands to be compiled, if necessary, and calls m.Run.

Types

type FakeStdin

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

FakeStdin implements io.Reader and returns predefined list of answers, suitable for mocking standard input.

func NewFakeStdin

func NewFakeStdin(answers ...string) *FakeStdin

NewFakeStdin creates new FakeStdin value with given answers.

func (*FakeStdin) Count

func (fs *FakeStdin) Count() int

Count returns how many answers have been read.

This counter overflows and never returns value bigger than the count of given answers.

func (*FakeStdin) Overflowed

func (fs *FakeStdin) Overflowed() bool

Overflowed reports whether more reads happened than expected.

func (*FakeStdin) Read

func (fs *FakeStdin) Read(p []byte) (int, error)

Read answers one by one and keep record whether the stdin has overflowed.

Jump to

Keyboard shortcuts

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