testing

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	OCTET_STREAM = "application/octet-stream"
	JSON         = "application/json; charset=utf-8"
	TEXT         = "text/plain"
)

Variables

View Source
var DefaultRoundTripper http.RoundTripper = &http.Transport{
	Proxy: http.ProxyFromEnvironment,
	DialContext: (&net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
	}).DialContext,
	MaxIdleConns:          100,
	IdleConnTimeout:       90 * time.Second,
	TLSHandshakeTimeout:   10 * time.Second,
	ExpectContinueTimeout: 1 * time.Second,
}

Functions

func ResetDefaultRoundTripper

func ResetDefaultRoundTripper()

Types

type CannedResponse added in v1.1.0

type CannedResponse struct {
	ResponseType ResponseType
	Response     string
	ContentType  string
}

type ExpectedCommand added in v1.3.0

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

type FakeRunner added in v1.3.0

type FakeRunner struct {
	*Runner
}

func NewFakeRunner added in v1.3.0

func NewFakeRunner(test *testing.T) *FakeRunner

func (*FakeRunner) ExpectAndReturn added in v1.3.0

func (f *FakeRunner) ExpectAndReturn(input string, output string)

type MockRoundTripper

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

MockRoundTripper mocks HTTP requests and allows to return canned responses

func NewMockRoundTripper

func NewMockRoundTripper() *MockRoundTripper

func (*MockRoundTripper) AllowDelegation added in v1.1.0

func (t *MockRoundTripper) AllowDelegation(delegate bool)

func (*MockRoundTripper) RegisterResponse added in v1.1.0

func (t *MockRoundTripper) RegisterResponse(url string, response *CannedResponse)

func (*MockRoundTripper) RoundTrip

func (t *MockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

func (*MockRoundTripper) Verbose added in v1.1.0

func (t *MockRoundTripper) Verbose(verbose bool)

type ResponseType added in v1.1.0

type ResponseType int
const (
	SERVE_STRING ResponseType = iota
	SERVE_FILE
)

type Runner added in v1.3.0

type Runner struct{}

func (*Runner) Output added in v1.3.0

func (f *Runner) Output(command string, args ...string) ([]byte, error)

func (*Runner) Run added in v1.3.0

func (f *Runner) Run(stdOut io.Writer, stdErr io.Writer, commandPath string, args ...string) int

type Tee added in v1.10.0

type Tee struct {
	OrigStdout   *os.File
	OrigStderr   *os.File
	Stdout       *os.File
	Stderr       *os.File
	StdoutBuffer *bytes.Buffer
	StderrBuffer *bytes.Buffer
	// contains filtered or unexported fields
}

func NewTee added in v1.10.0

func NewTee(silent bool) (*Tee, error)

NewTee splits os.Stdout and os.Stderr using a pipe. While the tee is not closed data written to stdout or stderr will be copied into a buffer as well well as printed to the original file handle, unless silent is true, in which case the original output streams are silenced.

func (*Tee) Close added in v1.10.0

func (t *Tee) Close()

Jump to

Keyboard shortcuts

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