exec

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package provides wrapper around os.exec for purpose of testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd interface {
	StdinPipe() (io.WriteCloser, error)
	CombinedOutput() ([]byte, error)
	Start() error
	Wait() error
}

Cmd is a facade to exec.Cmd.

type DefaultExecutor

type DefaultExecutor struct{}

DefaultExecutor is a default implementation of Executable that passes back to standard library.

func (DefaultExecutor) Cmd

func (DefaultExecutor) Cmd(cmd string, args []string) Cmd

Cmd implements Executable interface.

func (DefaultExecutor) Exec

func (DefaultExecutor) Exec(cmd string, args []string) ([]byte, error)

Exec implements Executable interface by proxiyng all requests to exec.Command().

type Executable

type Executable interface {
	Exec(cmd string, args []string) ([]byte, error)
	Cmd(cmd string, args []string) Cmd
}

Executable is a facade to exec.Command().Output().

type FakeCmd

type FakeCmd struct{}

FakeCmd implement Cmd interface for testing purposes.

func (FakeCmd) CombinedOutput

func (FakeCmd) CombinedOutput() ([]byte, error)

func (FakeCmd) Start

func (FakeCmd) Start() error

func (FakeCmd) StdinPipe

func (FakeCmd) StdinPipe() (io.WriteCloser, error)

func (FakeCmd) Wait

func (FakeCmd) Wait() error

type FakeExecutor

type FakeExecutor struct {
	Output   []byte
	Error    error
	Commands *string
}

FakeExecutor implements Executable stores faked Output, Error and commands recorded by Exec.

func (*FakeExecutor) Cmd

func (x *FakeExecutor) Cmd(cmd string, args []string) Cmd

func (*FakeExecutor) Exec

func (x *FakeExecutor) Exec(cmd string, args []string) ([]byte, error)

Exec is a method of fake executor that will record all incoming commands and use faked Output and Error.

Jump to

Keyboard shortcuts

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