exec

package
v1.3.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package exec provides an os/exec wrapper that can be overridden for testing purposes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTestProgram

func AddTestProgram(path string)

AddTestProgram takes the full path to a program and allows that program to be be found via LookPath().

func AddTestResult

func AddTestResult(command string, output string, err error)

AddTestResult tells exec to expect a call to Exec() with the given command line, and to return the given output or error in response. You must call AddTestResult() once for every time that Exec() will be called, in order.

func Exec

func Exec(cmd string, args ...string) (string, error)

Exec executes a command with the given arguments and returns either the combined stdout+stdin, or an error.

func LookPath

func LookPath(program string) (string, error)

LookPath looks for a program in $PATH and returns either the full path or an error

func SetTestMode

func SetTestMode()

SetTestMode turns on "test mode". In test mode, the output of LookPath() and Exec() is determined by prior calls to AddTestProgram() and AddTestResult().

Types

type TestResult

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

Jump to

Keyboard shortcuts

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