test

package
v0.0.0-...-c984151 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HandlerFunc http.HandlerFunc

Functions

func AssertStatus

func AssertStatus(t *testing.T, status int, method, url string, values url.Values, headers map[string]string) string

AssertStatus fails a test if the response status doesn't match the expected status

func CreateAppStackCycle

func CreateAppStackCycle(appName string) awsutil.Cycle

func CreateAppStackExistsCycle

func CreateAppStackExistsCycle(appName string) awsutil.Cycle

func DeleteStackCycle

func DeleteStackCycle(stackName string) awsutil.Cycle

func DescribeAppStackCycle

func DescribeAppStackCycle(stackName string) awsutil.Cycle

returns the stack you asked for

func DescribeConvoxStackCycle

func DescribeConvoxStackCycle(stackName string) awsutil.Cycle

returns convox stack

func DescribeStackCycleWithoutQuery

func DescribeStackCycleWithoutQuery(appName string) awsutil.Cycle

no filter - returns convox stack and an app

func DescribeStackNotFound

func DescribeStackNotFound(stackName string) awsutil.Cycle

search for stack, return missing

func GetAppTemplateCycle

func GetAppTemplateCycle(stackName string) awsutil.Cycle

func HTTPBody

func HTTPBody(method, url string, values url.Values, headers map[string]string) string

HTTPBody reads the HTTP response body as a string

func InspectCycle

func InspectCycle(id string) awsutil.Cycle

func ListECSContainersCycle

func ListECSContainersCycle() awsutil.Cycle

func ListECSOneoffContainersCycle

func ListECSOneoffContainersCycle() awsutil.Cycle

func ListOneoffContainersCycle

func ListOneoffContainersCycle(id string) awsutil.Cycle

func ListOneoffContainersEmptyCycle

func ListOneoffContainersEmptyCycle() awsutil.Cycle

func Runs

func Runs(t *testing.T, runs ...Run)

func Server

func Server(t *testing.T, stubs ...Http) *httptest.Server

func StatsCycle

func StatsCycle() awsutil.Cycle

func StubAws

func StubAws(cycles ...awsutil.Cycle) (s *httptest.Server)

func StubDocker

func StubDocker(cycles ...awsutil.Cycle) (s *httptest.Server)

Create a test server that mocks an Docker request/response cycle, suitable for a single test

Example:

s := StubDocker(ListContainersCycle())
defer s.Close()

d, _ := Docker(test.TestConfig.DockerHost)
d.ListContainers(...)

Types

type ErrorNotFound

type ErrorNotFound string

ErrorNotFound means the requested item was not found

func (ErrorNotFound) Error

func (e ErrorNotFound) Error() string

Error satisfies the error interface

func (ErrorNotFound) NotFound

func (e ErrorNotFound) NotFound() bool

NotFound defines the behavior of this error

type ExecRun

type ExecRun struct {
	Command    string
	Env        map[string]string
	Exit       int
	Dir        string
	Stdin      string
	Stdout     string
	OutMatch   string
	OutMatches []string
	Stderr     string
	Dump       bool
}

func (ExecRun) Test

func (er ExecRun) Test(t *testing.T)

type HandlerFuncTest

type HandlerFuncTest struct {
	Handler http.HandlerFunc
	// contains filtered or unexported fields
}

HandlerFuncTest is a helper for running tests on http.HandlerFunc

func NewHandlerFunc

func NewHandlerFunc(handler http.HandlerFunc) HandlerFuncTest

NewHandlerFunc returns a new HandlerFuncTest

func (*HandlerFuncTest) AssertCode

func (f *HandlerFuncTest) AssertCode(t *testing.T, code int)

AssertCode asserts the response code

func (*HandlerFuncTest) AssertError

func (f *HandlerFuncTest) AssertError(t *testing.T, message string)

AssertError asserts a response error

func (*HandlerFuncTest) AssertJSON

func (f *HandlerFuncTest) AssertJSON(t *testing.T, body string)

AssertJSON assets a JSON response (ignoring whitespace differences)

func (*HandlerFuncTest) AssertSuccess

func (f *HandlerFuncTest) AssertSuccess(t *testing.T)

AssertSuccess asserts a successful response

func (*HandlerFuncTest) Body

func (f *HandlerFuncTest) Body() []byte

Body returns the response body

func (*HandlerFuncTest) Code

func (f *HandlerFuncTest) Code() int

Code returns the response code

func (*HandlerFuncTest) Request

func (f *HandlerFuncTest) Request(method, url string, values url.Values) error

Request executes an HTTP request against the tester

func (*HandlerFuncTest) SetVersion

func (f *HandlerFuncTest) SetVersion(version string)

SetVersion sets the Version: HTTP header

type Http

type Http struct {
	Method   string
	Path     string
	Code     int
	Body     string
	Headers  map[string]string
	Response interface{}
}

type Run

type Run interface {
	Test(*testing.T)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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