Documentation ¶
Overview ¶
Package litmus provides common unit testing tools used in atomic projects
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Context is a mocked context.Context Context = mock.AnythingOfType("*context.valueCtx") // OperationArg is a convenience for referencing an arg OperationArg = func(a int, o ...int) *OperationRef { if len(o) > 0 { return &OperationRef{Index: o[0], Arg: a} } return &OperationRef{Index: 0, Arg: a} } // OperationReturn is a convenience for referencing a return OperationReturn = func(r int, o ...int) *OperationRef { if len(o) > 0 { return &OperationRef{Index: o[0], Return: r} } return &OperationRef{Index: 0, Return: r} } // NoRedirect forces no redirects NoRedirect = func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse } )
Functions ¶
This section is empty.
Types ¶
type Mock ¶ added in v0.5.4
Mock is the litmus mock wrapper
func (*Mock) Called ¶ added in v0.5.4
Called tells the mock object that a method has been called, and gets an array of arguments to return. Panics if the call is unexpected (i.e. not preceded by appropriate .On .Return() calls) If Call.WaitFor is set, blocks until the channel is closed or receives a message.
type Operation ¶ added in v0.4.0
type Operation struct { // Name is the operation name Name string // Args is the operation args Args []interface{} // Returns in the operation returns Returns []interface{} // ReturnStack handles a return stack for multiple calls ReturnStack [][]interface{} // Optional backend for this operation Backend *mock.Mock // contains filtered or unexported fields }
Operation is a backend operation
type OperationRef ¶ added in v0.4.0
type OperationRef struct { // Index refers the operation slice index Index int // Arg refers to the Args index Arg int // Return refers to the Returns index Return int }
OperationRef is used to reference on operation
type RequestHandler ¶ added in v0.5.0
RequestHandler can be used to generate a request body dynamically
type ReturnStack ¶ added in v0.5.4
type ReturnStack [][]interface{}
ReturnStack handles a return stack
type Test ¶
type Test struct { // Operations are the backend operations to prepare for test Operations []Operation // Method the http method Method string // The request path Path string // Query is the request query parameters Query url.Values // Request is the http request body put on the wire // []byte or string will be posted directly // if Request is *OperationRef that value will be used // everything else will be marshalled to json Request interface{} // RequestContentType is the request content type, default application/json RequestContentType string // ExpectedStatus is the expected http status ExpectedStatus int // ExpectedHeaders are expected response headers ExpectedHeaders map[string]string // ExpectedContentType is the expected content-type ExpectedContentType string // ExpectedResponse is expected wire response // []byte or string will be posted directly // if Request is *OperationRef that value will be used // everything else will be marshalled to json ExpectedResponse interface{} // Redirect overrides the http client redirect Redirect func(req *http.Request, via []*http.Request) // Setup is call before the request is executed Setup func(r *http.Request) }
Test is a test requirements object
Click to show internal directories.
Click to hide internal directories.