Documentation ¶
Index ¶
- func Do(steps ...IStep) error
- func MustDo(steps ...IStep)
- func Test(t TestingT, steps ...IStep)
- type Callback
- type HTTPBody
- func (body *HTTPBody) Bool() bool
- func (body *HTTPBody) Bytes() []byte
- func (body *HTTPBody) Float32() float32
- func (body *HTTPBody) Float64() float64
- func (body *HTTPBody) Int() int
- func (body *HTTPBody) Int16() int16
- func (body *HTTPBody) Int32() int32
- func (body *HTTPBody) Int64() int64
- func (body *HTTPBody) Int8() int8
- func (body *HTTPBody) JSON() *HTTPJson
- func (body *HTTPBody) Reader() io.ReadCloser
- func (body *HTTPBody) Set(data interface{})
- func (body *HTTPBody) SetBool(b bool)
- func (body *HTTPBody) SetBytes(b []byte)
- func (body *HTTPBody) SetFloat32(f float32)
- func (body *HTTPBody) SetFloat64(f float64)
- func (body *HTTPBody) SetInt(i int)
- func (body *HTTPBody) SetInt16(i int16)
- func (body *HTTPBody) SetInt32(i int32)
- func (body *HTTPBody) SetInt64(i int64)
- func (body *HTTPBody) SetInt8(i int8)
- func (body *HTTPBody) SetReader(r io.Reader)
- func (body *HTTPBody) SetString(s string)
- func (body *HTTPBody) SetStringf(format string, a ...interface{})
- func (body *HTTPBody) SetUint(i uint)
- func (body *HTTPBody) SetUint16(i uint16)
- func (body *HTTPBody) SetUint32(i uint32)
- func (body *HTTPBody) SetUint64(i uint64)
- func (body *HTTPBody) SetUint8(i uint8)
- func (body *HTTPBody) String() string
- func (body *HTTPBody) Uint() uint
- func (body *HTTPBody) Uint16() uint16
- func (body *HTTPBody) Uint32() uint32
- func (body *HTTPBody) Uint64() uint64
- func (body *HTTPBody) Uint8() uint8
- type HTTPJson
- type HTTPRequest
- type HTTPResponse
- type Hit
- type IClear
- type IClearExpect
- type IClearExpectBody
- type IClearExpectBodyJSON
- type IClearExpectHeader
- type IClearExpectStatus
- type IClearSend
- type IClearSendBody
- type IExpect
- type IExpectBody
- type IExpectBodyJSON
- type IExpectHeader
- type IExpectStatus
- type ISend
- type ISendBody
- type IStep
- func BaseURL(url string, a ...interface{}) IStep
- func CombineSteps(steps ...IStep) IStep
- func Connect(url string, a ...interface{}) IStep
- func Custom(when StepTime, exec Callback) IStep
- func Debug(expression ...string) IStep
- func Delete(url string, a ...interface{}) IStep
- func Description(description string) IStep
- func Get(url string, a ...interface{}) IStep
- func HTTPClient(client *http.Client) IStep
- func Head(url string, a ...interface{}) IStep
- func Method(method, url string, a ...interface{}) IStep
- func Options(url string, a ...interface{}) IStep
- func Post(url string, a ...interface{}) IStep
- func Put(url string, a ...interface{}) IStep
- func Request(request *http.Request) IStep
- func Stdout(w io.Writer) IStep
- func Trace(url string, a ...interface{}) IStep
- type PanicT
- type StepTime
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HTTPBody ¶
type HTTPBody struct {
// contains filtered or unexported fields
}
func (*HTTPBody) Reader ¶
func (body *HTTPBody) Reader() io.ReadCloser
getters Reader returns the body as an reader
func (*HTTPBody) Set ¶
func (body *HTTPBody) Set(data interface{})
Set sets the body to the specified value
func (*HTTPBody) SetFloat32 ¶
SetFloat32 sets the body to the specified float32
func (*HTTPBody) SetFloat64 ¶
SetFloat64 sets the body to the specified float64
func (*HTTPBody) SetReader ¶
setters SetReader sets the body to the contents of the specified reader
func (*HTTPBody) SetStringf ¶
SetStringf sets the body to the specified string format
type HTTPJson ¶
type HTTPJson struct { Hit // contains filtered or unexported fields }
type HTTPRequest ¶
func (*HTTPRequest) Body ¶
func (req *HTTPRequest) Body() *HTTPBody
type HTTPResponse ¶
func (*HTTPResponse) Body ¶
func (r *HTTPResponse) Body() *HTTPBody
type Hit ¶
type Hit interface { // Request returns the current request Request() *HTTPRequest // SetRequest sets the request for the current instance SetRequest(request *http.Request) // Response returns the current Response Response() *HTTPResponse // HTTPClient gets the current http.Client HTTPClient() *http.Client // SetHTTPClient sets the client for the request SetHTTPClient(client *http.Client) // Stdout gets the current output Stdout() io.Writer // SetStdout sets the output to the specified writer SetStdout(w io.Writer) // BaseURL returns the current base url BaseURL() string // SetBaseURL sets the base url SetBaseURL(url string, a ...interface{}) // CurrentStep returns the current working step CurrentStep() IStep // Steps returns the current step list Steps() []IStep // AddSteps appends the specified steps to the step list AddSteps(steps ...IStep) // InsertSteps inserts the specified steps right after the current step InsertSteps(steps ...IStep) // RemoveSteps removes the specified steps from the step list RemoveSteps(steps ...IStep) // Do runs the specified steps in in this context. // // Example: // Expect().Custom(func(hit Hit) { // err := Do( // Expect().Status(200), // ) // if err != nil { // panic(err) // } // }) Do(steps ...IStep) error // MustDo runs the specified steps in in this context and panics on failure // Example: // Expect().Custom(func(hit Hit) { // MustDo( // Expect().Status(200), // ) // }) MustDo(steps ...IStep) // Description gets the current description that will be printed in an error case Description() string // SetDescription sets a custom description for this test. // The description will be printed in an error case SetDescription(string) }
type IClear ¶
type IClear interface { // Send removes all previous Send() steps and all steps chained to Send() e.g. Send().Body("Hello World"). // // If you specify an argument it will only remove the Send() steps matching that argument. // // Usage: // Clear().Send() // will remove all Send() steps and all chained steps to Send() e.g. Send().Body("Hello World") // Clear().Send("Hello World") // will remove all Send("Hello World") steps // Clear().Send().Body() // will remove all Send().Body() steps and all chained steps to Body() e.g. Send().Body().Equal("Hello World") // Clear().Send().Body("Hello World") // will remove all Send().Body("Hello World") steps // // Example: // MustDo( // Post("https://example.com"), // Send("Hello Earth"), // Clear().Send(), // Send("Hello World"), // ) Send(value ...interface{}) IClearSend // Expect removes all previous Expect() steps and all steps chained to Expect() e.g. Expect().Body("Hello World"). // // If you specify an argument it will only remove the Expect() steps matching that argument. // // Usage: // Clear().Expect() // will remove all Expect() steps and all chained steps to Expect() e.g. Expect().Body("Hello World") // Clear().Expect("Hello World") // will remove all Expect("Hello World") steps // Clear().Expect().Body() // will remove all Expect().Body() steps and all chained steps to Body() e.g. Expect().Body().Equal("Hello World") // Clear().Expect().Body("Hello World") // will remove all Expect().Body("Hello World") steps // // Example: // MustDo( // Post("https://example.com"), // Expect("Hello Earth"), // Clear().Expect(), // Expect("Hello World"), // ) Expect(value ...interface{}) IClearExpect }
IClear provides a clear functionality to remove previous steps from running
func Clear ¶
func Clear() IClear
Clear can be used to remove previous steps.
Usage:
Clear().Send("Hello World") // will remove all Send("Hello World") steps Clear().Send().Body("Hello World") // will remove all Send().Body("Hello World") steps Clear().Expect().Body() // will remove all Expect().Body() steps and all chained steps to Body() e.g. Expect().Body().Equal("Hello World") Clear().Expect().Body("Hello World") // will remove all Expect().Body("Hello World") steps
Example:
MustDo( Post("https://example.com"), Expect().Status(http.StatusOK), Expect().Body().Contains("Welcome to example.com"), Clear().Expect(), Expect().Status(http.NotFound), Expect().Body().Contains("Not found!"), )
type IClearExpect ¶
type IClearExpect interface { IStep // Body removes all previous Expect().Body() steps and all steps chained to Expect().Body() e.g. Expect().Body().Equal("Hello World"). // // If you specify an argument it will only remove the Expect().Body() steps matching that argument. // // Usage: // Clear().Expect().Body() // will remove all Expect().Body() steps and all chained steps to Expect() e.g. Expect().Body("Hello World") // Clear().Expect().Body("Hello World") // will remove all Expect().Body("Hello World") steps // Clear().Expect().Body().Equal() // will remove all Expect().Body().Equal() steps // Clear().Expect().Body().Equal("Hello World") // will remove all Expect().Body().Equal("Hello World") steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Body("Hello Earth"), // Clear().Expect().Body(), // Expect().Body("Hello World"), // ) Body(value ...interface{}) IClearExpectBody // Interface removes all previous Expect().Interface() steps. // // If you specify an argument it will only remove the Expect().Interface() steps matching that argument. // // Usage: // Clear().Expect().Interface() // will remove all Expect().Interface() steps // Clear().Expect().Interface("Hello World") // will remove all Expect().Interface("Hello World") steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Interface("Hello Earth"), // Clear().Expect().Interface(), // Expect().Interface("Hello World"), // ) Interface(value ...interface{}) IStep // Custom removes all previous Expect().Custom() steps. // // If you specify an argument it will only remove the Expect().Custom() steps matching that argument. // // Usage: // Clear().Expect().Custom(fn) // will remove all Expect().Custom(fn) steps // Clear().Expect().Custom() // will remove all Expect().Custom() steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Custom(func(hit Hit) { // if hit.Response().Body().String() != "Hello Earth" { // panic("Expected Hello Earth") // } // }), // Clear().Expect().Custom(), // Expect().Custom(func(hit Hit) { // if hit.Response().Body().String() != "Hello World" { // panic("Expected Hello World") // } // }), // ) Custom(fn ...Callback) IStep // Header removes all previous Expect().Header() steps and all steps chained to Expect().Header() // e.g. Expect().Header("Content-Type").Equal("Content-Type"). // // If you specify an argument it will only remove the Expect().Header() steps matching that argument. // // Usage: // Clear().Expect().Header() // will remove all Expect().Header() steps and all chained steps to Expect().Header() e.g Expect().Header("Content-Type").Equal("Content-Type") // Clear().Expect().Header("Content-Type") // will remove all Expect().Header("Content-Type") steps and all chained steps to Expect().Header("Content-Type") e.g. Expect().Header("Content-Type").Equal("application/json") // Clear().Expect().Header("Content-Type").Equal() // will remove all Expect().Header("Content-Type").Equal() steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Header("Content-Type").Equal("application/json"), // Clear().Expect().Header(), // Expect().Header("Content-Type").Equal("application/octet-stream"), // ) Header(headerName ...string) IClearExpectHeader // Status removes all previous Expect().Status() steps and all steps chained to Expect().Status() // e.g. Expect().Status().Equal(http.StatusOK). // // If you specify an argument it will only remove the Expect().Status() steps matching that argument. // // Usage: // Clear().Expect().Status() // will remove all Expect().Status() steps and all chained steps to Expect().Status() e.g Expect().Status().Equal(http.StatusOK) // Clear().Expect().Status(http.StatusOK) // will remove all Expect().Status(http.StatusOK) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status(http.StatusNotFound), // Clear().Expect().Status(), // Expect().Status(http.StatusOK), // ) Status(code ...int) IClearExpectStatus }
IClearExpect provides a clear functionality to remove previous steps from running in the Expect() scope
type IClearExpectBody ¶
type IClearExpectBody interface { IStep // Interface removes all previous Expect().Body().Interface() steps. // // If you specify an argument it will only remove the Expect().Body().Interface() steps matching that argument. // // Usage: // Clear().Expect().Body().Interface() // will remove all Expect().Body().Interface() steps and all chained steps to Interface() e.g. Expect().Body().Interface().Equal(map[string]interface{}{"Name": "Joe"}) // Clear().Expect().Body().Interface(map[string]interface{}{"Name": "Joe"}) // will remove all Expect().Body().Interface(map[string]interface{}{"Name": "Joe"}) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Body().Interface(map[string]interface{}{"Name": "Joe"}), // Clear().Expect().Body().Interface(), // Expect().Body().Interface(map[string]interface{}{"Name": "Alice"}), // ) Interface(value ...interface{}) IStep // JSON removes all previous Expect().Body().JSON() steps and all steps chained to Expect().Body().JSON() // e.g. Expect().Body().JSON().Equal(map[string]interface{}{"Name": "Joe"}). // // If you specify an argument it will only remove the Expect().Body().JSON() steps matching that argument. // // Usage: // Clear().Expect().Body().JSON() // will remove all Expect().Body().JSON() steps and all chained steps to JSON() e.g. Expect().Body().JSON().Equal(map[string]interface{}{"Name": "Joe"}) // Clear().Expect().Body().JSON(map[string]interface{}{"Name": "Joe"}) // will remove all Expect().Body().JSON(map[string]interface{}{"Name": "Joe"}) steps // Clear().Expect().Body().JSON().Equal() // will remove all Expect().Body().JSON().Equal() steps // Clear().Expect().Body().JSON().Equal(map[string]interface{}{"Name": "Joe"}) // will remove all Expect().Body().JSON().Equal(map[string]interface{}{"Name": "Joe"}) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Body().JSON(map[string]interface{}{"Name": "Joe"}), // Clear().Expect().Body().JSON(), // Expect().Body().JSON(map[string]interface{}{"Name": "Alice"}), // ) JSON(value ...interface{}) IClearExpectBodyJSON // Equal removes all previous Expect().Body().Equal() steps. // // If you specify an argument it will only remove the Expect().Body().Equal() steps matching that argument. // // Usage: // Clear().Expect().Body().Equal() // will remove all Expect().Body().Equal() steps // Clear().Expect().Body().Equal("Hello World") // will remove all Expect().Body().Equal("Hello World") steps // // Example: // Do( // Post("https://example.com"), // Expect().Body().Equal("Hello Earth"), // Clear().Expect().Body().Equal(), // Expect().Body().Equal("Hello World"), // ) Equal(value ...interface{}) IStep // NotEqual removes all previous Expect().Body().NotEqual() steps. // // If you specify an argument it will only remove the Expect().Body().NotEqual() steps matching that argument. // // Usage: // Clear().Expect().Body().NotEqual() // will remove all Expect().Body().NotEqual() steps // Clear().Expect().Body().NotEqual("Hello World") // will remove all Expect().Body().NotEqual("Hello World") steps // // Example: // Do( // Post("https://example.com"), // Expect().Body().NotEqual("Hello World"), // Clear().Expect().Body().NotEqual(), // Expect().Body().NotEqual("Hello Earth"), // ) NotEqual(value ...interface{}) IStep // Contains removes all previous Expect().Body().Contains() steps. // // If you specify an argument it will only remove the Expect().Body().Contains() steps matching that argument. // // Usage: // Clear().Expect().Body().Contains() // will remove all Expect().Body().Contains() steps // Clear().Expect().Body().Contains("Hello World") // will remove all Expect().Body().Contains("Hello World") steps // // Examples: // Do( // Post("https://example.com"), // Expect().Body().Contains("Hello Earth"), // Clear().Expect().Body().Contains(), // Expect().Body().Contains("Hello World"), // ) Contains(value ...interface{}) IStep // NotContains removes all previous Expect().Body().NotContains() steps. // // If you specify an argument it will only remove the Expect().Body().NotContains() steps matching that argument. // // Usage: // Clear().Expect().Body().NotContains() // will remove all Expect().Body().NotContains() steps // Clear().Expect().Body().NotContains("Hello World") // will remove all Expect().Body().NotContains("Hello World") steps // // Example: // Do( // Post("https://example.com"), // Expect().Body().NotContains("Hello World"), // Clear().Expect().Body().NotContains(), // Expect().Body().NotContains("Hello Earth"), // ) NotContains(value ...interface{}) IStep }
IClearExpectBody provides a clear functionality to remove previous steps from running in the Expect().Body() scope
type IClearExpectBodyJSON ¶
type IClearExpectBodyJSON interface { IStep // Equal removes all previous Expect().Body().JSON().Equal() steps. // // If you specify an argument it will only remove the Expect().Body().Equal() steps matching that argument. // // Usage: // Clear().Expect().Body().JSON().Equal() // will remove all Expect().Body().JSON().Equal() steps // Clear().Expect().Body().JSON().Equal("Name") // will remove all Expect().Body().JSON().Equal("Name", ...) steps // Clear().Expect().Body().JSON().Equal("Name", "Joe") // will remove all Expect().Body().JSON().Equal("Name", "Joe") steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Body().JSON().Equal("Name", "Joe"), // Expect().Body().JSON().Equal("Id", 10), // Clear().Expect().Body().JSON().Equal("Name"), // Clear().Expect().Body().JSON().Equal("Id", 10), // Expect().Body().JSON().Equal("Name", "Alice"), // ) Equal(value ...interface{}) IStep // NotEqual removes all previous Expect().Body().JSON().NotEqual() steps. // // If you specify an argument it will only remove the Expect().Body().NotEqual() steps matching that argument. // // Usage: // Clear().Expect().Body().JSON().NotEqual() // will remove all Expect().Body().JSON().NotEqual() steps // Clear().Expect().Body().JSON().NotEqual("Name") // will remove all Expect().Body().JSON().NotEqual("Name") steps // Clear().Expect().Body().JSON().NotEqual("Name", "Joe") // will remove all Expect().Body().JSON().NotEqual("Name", "Joe") steps // // Example: // Do( // Post("https://example.com"), // Expect().Body().JSON().NotEqual("Name", "Joe"), // Expect().Body().JSON().NotEqual("Id", 10), // Clear().Expect().Body().JSON().NotEqual("Name"), // Clear().Expect().Body().JSON().NotEqual("Id", 10), // Expect().Body().JSON().NotEqual("Name", "Alice"), // ) NotEqual(value ...interface{}) IStep // Contains removes all previous Expect().Body().JSON().Contains() steps. // // If you specify an argument it will only remove the Expect().Body().Contains() steps matching that argument. // // Usage: // Clear().Expect().Body().JSON().Contains() // will remove all Expect().Body().JSON().Contains() steps // Clear().Expect().Body().JSON().Contains("Name") // will remove all Expect().Body().JSON().Contains("Name") steps // Clear().Expect().Body().JSON().Contains("Name", "Joe") // will remove all Expect().Body().JSON().Contains("Name", "Joe") steps // // Example: // Do( // Post("https://example.com"), // Expect().Body().JSON().Contains("Name", "Joe"), // Expect().Body().JSON().Contains("Id", 10), // Clear().Expect().Body().JSON().Contains("Name"), // Clear().Expect().Body().JSON().Contains("Id", 10), // Expect().Body().JSON().Contains("Name", "Alice"), // ) Contains(value ...interface{}) IStep // NotContains removes all previous Expect().Body().JSON().NotContains() steps. // // If you specify an argument it will only remove the Expect().Body().NotContains() steps matching that argument. // // Usage: // Clear().Expect().Body().JSON().NotContains() // will remove all Expect().Body().JSON().NotContains() steps // Clear().Expect().Body().JSON().NotContains("Name") // will remove all Expect().Body().JSON().NotContains("Name") steps // Clear().Expect().Body().JSON().NotContains("Name", "Joe") // will remove all Expect().Body().JSON().NotContains("Name", "Joe") steps // // Example: // Do( // Post("https://example.com"), // Expect().Body().JSON().NotContains("Name", "Joe"), // Expect().Body().JSON().NotContains("Id", 10), // Clear().Expect().Body().JSON().NotContains("Name"), // Clear().Expect().Body().JSON().NotContains("Id", 10), // Expect().Body().JSON().NotContains("Name", "Alice"), // ) NotContains(value ...interface{}) IStep }
IClearExpectBody provides a clear functionality to remove previous steps from running in the Expect().Body().JSON() scope
type IClearExpectHeader ¶
type IClearExpectHeader interface { IStep // Contains removes all previous Expect().Header(...).Contains() steps. // // If you specify an argument it will only remove the Expect().Header(...).Contains() steps matching that argument. // // Usage: // Clear().Expect().Header().Contains() // will remove all Expect().Header().Contains() steps // Clear().Expect().Header().Contains("Content-Type") // will remove all Expect().Header().Contains("Content-Type") steps // Clear().Expect().Header("Content-Type").Contains() // will remove all Expect().Header("Content-Type").Contains() steps // Clear().Expect().Header("Content-Type").Contains("json") // will remove all Expect().Header("Content-Type").Contains("json") steps // // Examples: // MustDo( // Post("https://example.com"), // Expect().Header().Contains("Content-Type") // Clear().Expect().Header().Contains() // Expect().Header().Contains("Set-Cookie") // ) // MustDo( // Post("https://example.com"), // Expect().Header("Content-Type").Contains("json") // Clear().Expect().Header("Content-Type").Contains() // Expect().Header("Content-Type").Equal("application/json") // ) Contains(value ...interface{}) IStep // NotContains removes all previous Expect().Header(...).NotContains() steps. // // If you specify an argument it will only remove the Expect().Header(...).NotContains() steps matching that argument. // // Usage: // Clear().Expect().Header().NotContains() // will remove all Expect().Header().NotContains() steps // Clear().Expect().Header().NotContains("Content-Type") // will remove all Expect().Header().NotContains("Content-Type") steps // Clear().Expect().Header("Content-Type").NotContains() // will remove all Expect().Header("Content-Type").NotContains() steps // Clear().Expect().Header("Content-Type").NotContains("json") // will remove all Expect().Header("Content-Type").NotContains("json") steps // // Examples: // MustDo( // Post("https://example.com"), // Expect().Header().NotContains("Content-Type") // Clear().Expect().Header().NotContains() // Expect().Header().Contains("Set-Cookie") // ) // // MustDo( // Post("https://example.com"), // Expect().Header("Content-Type").NotContains("json") // Clear().Expect().Header("Content-Type").NotContains() // Expect().Header("Content-Type").Contains("xml") // ) NotContains(value ...interface{}) IStep // OneOf removes all previous Expect().Header(...).OneOf() steps. // // If you specify an argument it will only remove the Expect().Header(...).OneOf() steps matching that argument. // // USage: // Clear().Expect().Header("Content-Type").OneOf() // will remove all Expect().Header("Content-Type").OneOf() steps // Clear().Expect().Header("Content-Type").OneOf("json") // will remove all Expect().Header("Content-Type").OneOf("json") steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Header("Content-Type").OneOf("application/json", "application/xml") // Clear().Expect().Header("Content-Type").OneOf() // Expect().Header("Content-Type").Equal("application/json") // ) OneOf(values ...interface{}) IStep // NotOneOf removes all previous Expect().Header(...).NotOneOf() steps. // // If you specify an argument it will only remove the Expect().Header(...).NotOneOf() steps matching that argument. // // Usage: // Clear().Expect().Header("Content-Type").NotOneOf() // will remove all Expect().Header("Content-Type").NotOneOf() steps // Clear().Expect().Header("Content-Type").NotOneOf("json") // will remove all Expect().Header("Content-Type").NotOneOf("json") steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Header("Content-Type").NotOneOf("application/json", "application/xml") // Clear().Expect().Header("Content-Type").NotOneOf() // Expect().Header("Content-Type").NotOneOf("application/xml") // ) NotOneOf(values ...interface{}) IStep // Empty removes all previous Expect().Header(...).Empty() steps. // // Usage: // Clear().Expect().Header().Empty() // will remove all Expect().Header().Empty() steps // Clear().Expect().Header("Content-Type").Empty() // will remove all Expect().Header("Content-Type").Empty() steps // // Examples: // MustDo( // Post("https://example.com"), // Expect().Header().Empty() // Clear().Expect().Header().Empty() // Expect().Header().Contains("Content-Type") // ) // // MustDo( // Post("https://example.com"), // Expect().Header("Content-Type").Empty() // Clear().Expect().Header("Content-Type").Empty() // Expect().Header("Content-Type").Equal("application/json") // ) Empty() IStep // Len removes all previous Expect().Header(...).Len() steps. // // If you specify an argument it will only remove the Expect().Header(...).Len() steps matching that argument. // // Usage: // Clear().Expect().Header().Len() // will remove all Expect().Header().Len() steps // Clear().Expect().Header().Len(10) // will remove all Expect().Header().Len(10) steps // Clear().Expect().Header("Content-Type").Len() // will remove all Expect().Header("Content-Type").Len() steps // Clear().Expect().Header("Content-Type").Len(10) // will remove all Expect().Header("Content-Type").Len(10) steps // // Examples: // MustDo( // Post("https://example.com"), // Expect().Header().Len(1) // Clear().Expect().Header().Len() // Expect().Header().Len(2) // ) // // MustDo( // Post("https://example.com"), // Expect().Header("Content-Type").Len(10) // Clear().Expect().Header("Content-Type").Len() // Expect().Header("Content-Type").Len(20) // ) Len(size ...int) IStep // Equal removes all previous Expect().Header(...).Equal() steps. // // If you specify an argument it will only remove the Expect().Header(...).Equal() steps matching that argument. // // Usage: // Clear().Expect().Header().Equal() // will remove all Expect().Header().Equal() steps // Clear().Expect().Header().Equal(map[string]interface{}{"Content-Type": "application/json"}) // will remove all Expect().Header().Equal(map[string]interface{}{"Content-Type": "application/json"}) steps // Clear().Expect().Header("Content-Type").Equal() // will remove all Expect().Header("Content-Type").Equal() steps // Clear().Expect().Header("Content-Type").Equal("application/json") // will remove all Expect().Header("Content-Type").Equal("application/json") steps // // Examples: // MustDo( // Post("https://example.com"), // Expect().Header().Equal(map[string]interface{}{"Content-Type": "application/xml"}) // Clear().Expect().Header().Equal() // Expect().Header().Equal(map[string]interface{}{"Content-Type": "application/json"}) // ) // // MustDo( // Post("https://example.com"), // Expect().Header("Content-Type").Equal("application/xml") // Clear().Expect().Header("Content-Type").Equal("application/xml") // Expect().Header("Content-Type").Equal("application/json") // ) Equal(value ...interface{}) IStep // NotEqual removes all previous Expect().Header(...).NotEqual() steps. // // If you specify an argument it will only remove the Expect().Header(...).NotEqual() steps matching that argument. // // Usage: // Clear().Expect().Header().NotEqual() // will remove all Expect().Header().NotEqual() steps // Clear().Expect().Header().NotEqual(map[string]interface{}{"Content-Type": "application/json"}) // will remove all Expect().Header().NotEqual(map[string]interface{}{"Content-Type": "application/json"}) steps // Clear().Expect().Header("Content-Type").NotEqual() // will remove all Expect().Header("Content-Type").NotEqual() steps // Clear().Expect().Header("Content-Type").NotEqual("application/json") // will remove all Expect().Header("Content-Type").NotEqual("application/json") steps // // Examples: // MustDo( // Post("https://example.com"), // Expect().Header().NotEqual(map[string]interface{}{"Content-Type": "application/json"}) // Clear().Expect().Header().NotEqual() // Expect().Header().NotEqual(map[string]interface{}{"Content-Type": "application/xml"}) // ) // // MustDo( // Post("https://example.com"), // Expect().Header("Content-Type").NotEqual("application/json") // Clear().Expect().Header("Content-Type").NotEqual("application/json") // Expect().Header("Content-Type").NotEqual("application/xml") // ) NotEqual(value ...interface{}) IStep }
IClearExpectHeader provides a clear functionality to remove previous steps from running in the Expect().Header(...) scope
type IClearExpectStatus ¶
type IClearExpectStatus interface { IStep // Equal removes all previous Expect().Status().Equal() steps. // // If you specify an argument it will only remove the Expect().Status().Equal() steps matching that argument. // // Usage: // Clear().Expect().Status().Equal() // will remove all Expect().Status().Equal() steps // Clear().Expect().Status().Equal(http.StatusOK) // will remove all Expect().Status().Equal(http.StatusOK) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().Equal(http.StatusNotFound), // Clear().Expect().Status().Equal(), // Expect().Status().Equal(http.StatusOK), // ) Equal(code ...int) IStep // NotEqual removes all previous Expect().Status().NotEqual() steps. // // If you specify an argument it will only remove the Expect().Status().NotEqual() steps matching that argument. // // Usage: // Clear().Expect().Status().NotEqual() // will remove all Expect().Status().NotEqual() steps // Clear().Expect().Status().NotEqual(http.StatusOK) // will remove all Expect().Status().NotEqual(http.StatusOK) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().NotEqual(http.StatusOK), // Clear().Expect().Status().NotEqual(), // Expect().Status().NotEqual(http.StatusNotFound), // ) NotEqual(code ...int) IStep // OneOf removes all previous Expect().Status().OneOf() steps. // // If you specify an argument it will only remove the Expect().Status().OneOf() steps matching that argument. // // Usage: // Clear().Expect().Status().OneOf() // will remove all Expect().Status().OneOf() steps // Clear().Expect().Status().OneOf(http.StatusOK) // will remove all Expect().Status().OneOf(http.StatusOK) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().OneOf(http.StatusOK, http.StatusNoContent), // Clear().Expect().Status().OneOf(), // Expect().Status().OneOf(http.StatusOK), // ) OneOf(code ...int) IStep // NotOneOf removes all previous Expect().Status().NotOneOf() steps. // // If you specify an argument it will only remove the Expect().Status().NotOneOf() steps matching that argument. // // Usage: // Clear().Expect().Status().NotOneOf() // will remove all Expect().Status().NotOneOf() steps // Clear().Expect().Status().NotOneOf(http.StatusOK) // will remove all Expect().Status().NotOneOf(http.StatusOK) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().NotOneOf(http.StatusOK, http.StatusNoContent), // Clear().Expect().Status().NotOneOf(), // Expect().Status().NotOneOf(http.StatusNotFound), // ) NotOneOf(code ...int) IStep // GreaterThan removes all previous Expect().Status().GreaterThan() steps. // // If you specify an argument it will only remove the Expect().Status().GreaterThan() steps matching that argument. // // Usage: // Clear().Expect().Status().GreaterThan() // will remove all Expect().Status().GreaterThan() steps // Clear().Expect().Status().GreaterThan(http.StatusOK) // will remove all Expect().Status().GreaterThan(http.StatusOK) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().GreaterThan(http.StatusContinue), // Clear().Expect().Status().GreaterThan(), // Expect().Status().GreaterThan(http.StatusOK), // ) GreaterThan(code ...int) IStep // LessThan removes all previous Expect().Status().LessThan() steps. // // If you specify an argument it will only remove the Expect().Status().LessThan() steps matching that argument. // // Usage: // Clear().Expect().Status().LessThan() // will remove all Expect().Status().LessThan() steps // Clear().Expect().Status().LessThan(http.StatusOK) // will remove all Expect().Status().LessThan(http.StatusOK) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().LessThan(http.StatusBadRequest), // Clear().Expect().Status().LessThan(), // Expect().Status().LessThan(http.StatusInternalServerError), // ) LessThan(code ...int) IStep // GreaterOrEqualThan removes all previous Expect().Status().GreaterOrEqualThan() steps. // // If you specify an argument it will only remove the Expect().Status().GreaterOrEqualThan() steps matching that argument. // // Usage: // Clear().Expect().Status().GreaterOrEqualThan() // will remove all Expect().Status().GreaterOrEqualThan() steps // Clear().Expect().Status().GreaterOrEqualThan(http.StatusOK) // will remove all Expect().Status().GreaterOrEqualThan(http.StatusOK) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().GreaterOrEqualThan(http.StatusBadRequest), // Clear().Expect().Status().GreaterOrEqualThan(), // Expect().Status().GreaterOrEqualThan(http.StatusOK), // ) GreaterOrEqualThan(code ...int) IStep // GreaterOrEqualThan removes all previous Expect().Status().GreaterOrEqualThan() steps. // // If you specify an argument it will only remove the Expect().Status().GreaterOrEqualThan() steps matching that argument. // // Usage: // Clear().Expect().Status().GreaterOrEqualThan() // will remove all Expect().Status().GreaterOrEqualThan() steps // Clear().Expect().Status().GreaterOrEqualThan(http.StatusOK) // will remove all Expect().Status().GreaterOrEqualThan(http.StatusOK) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().GreaterOrEqualThan(http.StatusBadRequest), // Clear().Expect().Status().GreaterOrEqualThan(), // Expect().Status().GreaterOrEqualThan(http.StatusOK), // ) LessOrEqualThan(code ...int) IStep // Between removes all previous Expect().Status().Between() steps. // // If you specify an argument it will only remove the Expect().Status().Between() steps matching that argument. // // Usage: // Clear().Expect().Status().Between() // will remove all Expect().Status().Between() steps // Clear().Expect().Status().Between(http.StatusOK) // will remove all Expect().Status().Between(http.StatusOK) steps // Clear().Expect().Status().Between(http.StatusOK, http.StatusAccepted) // will remove all Expect().Status().Between(http.StatusOK, http.StatusAccepted) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().Between(http.StatusOK, http.StatusAccepted), // Clear().Expect().Status().Between(), // Expect().Status().Between(http.StatusBadRequest, http.StatusUnavailableForLegalReasons), // ) Between(code ...int) IStep // NotBetween removes all previous Expect().Status().NotBetween() steps. // // If you specify an argument it will only remove the Expect().Status().NotBetween() steps matching that argument. // // Usage: // Clear().Expect().Status().NotBetween() // will remove all Expect().Status().NotBetween() steps // Clear().Expect().Status().NotBetween(http.StatusOK) // will remove all Expect().Status().NotBetween(http.StatusOK) steps // Clear().Expect().Status().NotBetween(http.StatusOK, http.StatusAccepted) // will remove all Expect().Status().NotBetween(http.StatusOK, http.StatusAccepted) steps // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().NotBetween(http.StatusOK, http.StatusAccepted), // Clear().Expect().Status().NotBetween(), // Expect().Status().NotBetween(http.StatusBadRequest, http.StatusUnavailableForLegalReasons), // ) NotBetween(code ...int) IStep }
IClearExpectStatus provides a clear functionality to remove previous steps from running in the Expect().Status() scope
type IClearSend ¶
type IClearSend interface { IStep // Body removes all previous Send().Body() steps and all steps chained to Send().Body() e.g. Send().Body().Interface("Hello World"). // // If you specify an argument it will only remove the Send().Body() steps matching that argument. // // Usage: // Clear().Send().Body() // will remove all Send().Body() steps and all chained steps to Send() e.g. Send().Body("Hello World") // Clear().Send().Body("Hello World") // will remove all Send().Body("Hello World") steps // Clear().Send().Body().Interface() // will remove all Send().Body().Interface() steps // Clear().Send().Body().Interface("Hello World") // will remove all Send().Body().Interface("Hello World") steps // // Example: // MustDo( // Post("https://example.com"), // Send().Body("Hello Earth"), // Clear().Send().Body(), // Send().Body("Hello World"), // ) Body(value ...interface{}) IClearSendBody // Interface removes all previous Send().Interface() steps. // // If you specify an argument it will only remove the Send().Interface() steps matching that argument. // // Usage: // Clear().Send().Interface() // will remove all Send().Interface() steps // Clear().Send().Interface("Hello World") // will remove all Send().Interface("Hello World") steps // // Example: // MustDo( // Post("https://example.com"), // Send().Interface("Hello Earth"), // Clear().Send().Interface(), // Send().Interface("Hello World"), // ) Interface(value ...interface{}) IStep // JSON removes all previous Send().JSON() steps. // // If you specify an argument it will only remove the Send().JSON() steps matching that argument. // // Usage: // Clear().Send().JSON() // will remove all Send().JSON() steps // Clear().Send().JSON(map[string]interface{}{"Name": "Joe"}) // will remove all Send().JSON("Hello World") steps // // Example: // MustDo( // Post("https://example.com"), // Send().JSON(map[string]interface{}{"Name": "Joe"}), // Clear().Send().JSON(), // Send().JSON(map[string]interface{}{"Name": "Alice"}), // ) JSON(value ...interface{}) IStep // Header removes all previous Send().Header() steps. // // If you specify an argument it will only remove the Send().Header() steps matching that argument. // // Usage: // Clear().Send().Header() // will remove all Send().Header() steps // Clear().Send().Header("Content-Type") // will remove all Send().Header("Content-Type", ...) step // Clear().Send().Header("Content-Type", "application/json") // will remove all Send().Header("Content-Type", "application/json") steps // // Example: // MustDo( // Post("https://example.com"), // Send().Header("Content-Type", "application/xml"), // Clear().Send().Header("Content-Type"), // Send().Header("Content-Type", "application/json"), // ) Header(values ...interface{}) IStep // Custom removes all previous Send().Custom() steps. // // If you specify an argument it will only remove the Send().Custom() steps matching that argument. // // Usage: // Clear().Send().Custom(fn) // will remove all Send().Custom(fn) steps // Clear().Send().Custom() // will remove all Send().Custom() steps // // Example: // MustDo( // Post("https://example.com"), // Send().Custom(func(hit Hit) { // hit.Request().Body().SetString("Hello Earth") // }), // Clear().Send().Custom(), // Send().Custom(func(hit Hit) { // hit.Request().Body().SetString("Hello World") // }), // ) Custom(fn ...Callback) IStep }
IClearSend provides a clear functionality to remove previous steps from running in the Send() scope
type IClearSendBody ¶
type IClearSendBody interface { IStep // JSON removes all previous Send().Body().JSON() steps. // // If you specify an argument it will only remove the Send().Body().JSON() steps matching that argument. // // Usage: // Clear().Send().Body().JSON() // will remove all Send().Body().JSON() steps // Clear().Send().Body().JSON(map[string]interface{}{"Name": "Joe"}) // will remove all Send().Body().JSON(map[string]interface{}{"Name": "Joe"}) steps // // Example: // MustDo( // Post("https://example.com"), // Send().Body().JSON(map[string]interface{}{"Name": "Joe"}), // Clear().Send().Body().JSON(), // Send().Body().JSON(map[string]interface{}{"Name": "Alice"}), // ) JSON(...interface{}) IStep // Interface removes all previous Send().Body().Interface() steps. // // If you specify an argument it will only remove the Send().Body().Interface() steps matching that argument. // // Usage: // Clear().Send().Body().Interface() // will remove all Send().Body().Interface() steps // Clear().Send().Body().Interface("Hello World") // will remove all Send().Body().Interface("Hello World") steps // // Example: // MustDo( // Post("https://example.com"), // Send().Body().Interface("Hello Earth"), // Clear().Send().Body().Interface(), // Send().Body().Interface("Hello World"), // ) Interface(...interface{}) IStep }
IClearSendBody provides a clear functionality to remove previous steps from running in the Send().Body() scope
type IExpect ¶
type IExpect interface { IStep // Body expects the body to be equal the specified value // // If you omit the argument you can fine tune the assertions. // // Usage: // Expect().Body("Hello World") // Expect().Body().Contains("Hello World") // // Example: // MustDo( // Get("https://example.com"), // Expect().Body().Contains("Hello World"), // ) Body(value ...interface{}) IExpectBody // Interface expects the body to be equal the specified interface. // // Usage: // Expect().Interface("Hello World") // Expect().Interface(map[string]interface{}{"Name": "Joe"}) // // Example: // MustDo( // Get("https://example.com"), // Expect().Interface("Hello World"), // ) Interface(value interface{}) IStep // Header provides assertions to one specific response header. // // If you omit the argument you can fine tune the assertions. // // Usage: // Expect().Header().Contains("Content-Type") // Expect().Header("Content-Type").Equal("application/json") // // Example: // MustDo( // Get("https://example.com"), // Expect().Header().Contains("Content-Type"), // Expect().Header("Content-Type").Equal("application/json"), // ) Header(headerName ...string) IExpectHeader // Status expects the status to be the specified code. // // If you omit the argument you can fine tune the assertions. // // Usage: // Expect().Status(200) // Expect().Status().Equal(200) // // Example: // MustDo( // Get("https://example.com"), // Expect().Status().OneOf(http.StatusOk, http.StatusNoContent), // ) Status(code ...int) IExpectStatus // Custom can be used to expect a custom behaviour. // // Example: // MustDo( // Get("https://example.com"), // Expect().Custom(func(hit Hit) { // if hit.Response().StatusCode != 200 { // panic("Expected 200") // } // }), // ) Custom(fn Callback) IStep }
IExpect provides assertions on the http response
type IExpectBody ¶
type IExpectBody interface { IStep // Interface expects the body to be equal the specified interface. // // Usage: // Expect().Body().Interface("Hello World") // Expect().Body().Interface(map[string]interface{}{"Name": "Joe"}) // // Example: // MustDo( // Get("https://example.com"), // Expect().Body().Interface("Hello World"), // ) Interface(data interface{}) IStep // JSON expects the body to be equal the specified value. // // If you omit the argument you can fine tune the assertions. // // Usage: // Expect().Body().JSON([]int{1, 2, 3}) // Expect().Body().JSON().Contains(1) // // Example: // MustDo( // Get("https://example.com"), // Expect().Body().JSON(map[string]interface{}{"Name": "Joe"}), // ) JSON(value ...interface{}) IExpectBodyJSON // Equal expects the body to be equal to the specified value // // Usage: // Expect().Body().Equal("Hello World") // // Example: // MustDo( // Get("https://example.com"), // Expect().Body().Equal("Hello World"), // ) Equal(value interface{}) IStep // NotEqual expects the body to be not equal to the specified value // // Usage: // Expect().Body().NotEqual("Hello World") // // Example: // MustDo( // Get("https://example.com"), // Expect().Body().NotEqual("Hello World"), // ) NotEqual(value interface{}) IStep // Contains expects the body to contain the specified value // // Usage: // Expect().Body().Contains("Hello World") // // Example: // MustDo( // Get("https://example.com"), // Expect().Body().Contains("Hello World"), // ) Contains(value interface{}) IStep // NotContains expects the body to not contain the specified value // // Usage: // Expect().Body().NotContains("Hello World") // // Example: // MustDo( // Get("https://example.com"), // Expect().Body().NotContains("Hello World"), // ) NotContains(value interface{}) IStep }
IExpectBody provides assertions on the http response body
type IExpectBodyJSON ¶
type IExpectBodyJSON interface { IStep // Equal expects the json body to be equal to the specified value. // // The first argument can be used to narrow down the compare path // // given the following response: { "ID": 10, "Name": "Joe", "Roles": ["Admin", "User"] } // Usage: // Expect().Body().JSON().Equal("", map[string]interface{}{"ID": 10, "Name": "Joe", "Roles": []string{"Admin", "User"}}) // Expect().Body().JSON().Equal("ID", 10) // Expect().Body().JSON().Equal("Name", "Joe") // Expect().Body().JSON().Equal("Roles", []string{"Admin", "User"}), // Expect().Body().JSON().Equal("Roles.0", "Admin"), // // Example: // // given the following response: { "ID": 10, "Name": "Joe", "Roles": ["Admin", "User"] } // MustDo( // Get("https://example.com"), // Expect().Body().JSON().Equal("Name", "Joe"), // Expect().Body().JSON().Equal("Roles", []string{"Admin", "User"}), // Expect().Body().JSON().Equal("Roles.0", "Admin"), // ) Equal(expression string, data interface{}) IStep // NotEqual expects the json body to be equal to the specified value. // // The first argument can be used to narrow down the compare path // // see Equal() for usage and examples NotEqual(expression string, data interface{}) IStep // Contains expects the json body to be equal to the specified value. // // The first argument can be used to narrow down the compare path // // given the following response: { "ID": 10, "Name": "Joe", "Roles": ["Admin", "User"] } // Usage: // Expect().Body().JSON().Contains("", "ID") // Expect().Body().JSON().Contains("Name", "J") // Expect().Body().JSON().Contains("Roles", "Admin"), // // Example: // // given the following response: { "ID": 10, "Name": "Joe", "Roles": ["Admin", "User"] } // MustDo( // Get("https://example.com"), // Expect().Body().JSON().Contains("", "ID"), // ) Contains(expression string, data interface{}) IStep // NotContains expects the json body to be equal to the specified value. // // The first argument can be used to narrow down the compare path // // see Contains() for usage and examples NotContains(expression string, data interface{}) IStep }
IExpectBodyJSON provides assertions on the http response json body
type IExpectHeader ¶
type IExpectHeader interface { // Contains expects the specified header to contain the specified value. // // Usage: // Expect().Header().Contains("Content-Type") // Expect().Header("Content-Type").Contains("json") // // Example: // MustDo( // Get("https://example.com"), // Expect().Header().Contains("Content-Type"), // Expect().Header("Content-Type").Contains("json"), // ) Contains(value interface{}) IStep // NotContains expects the specified header to contain the specified value. // // Usage: // Expect().Header().NotContains("Content-Type") // Expect().Header("Content-Type").NotContains("json") // // Example: // MustDo( // Get("https://example.com"), // Expect().Header().NotContains("Set-Cookie"), // Expect().Header("Content-Type").NotContains("json"), // ) NotContains(value interface{}) IStep // OneOf expects the specified header to contain one of the specified values. // // Usage: // Expect().Header().OneOf(map[string]string{"Content-Type": "application/json"}, map[string]string{"Content-Type": "text/json"}) // Expect().Header("Content-Type").OneOf("application/json", "text/json") // // Example: // MustDo( // Get("https://example.com"), // Expect().Header("Content-Type").OneOf("application/json", "text/json"), // ) OneOf(values ...interface{}) IStep // NotOneOf expects the specified header to not contain one of the specified values. // // Usage: // Expect().Header().NotOneOf(map[string]string{"Content-Type": "application/json"}, map[string]string{"Content-Type": "text/json"}) // Expect().Header("Content-Type").NotOneOf("application/json", "text/json") // // Example: // MustDo( // Get("https://example.com"), // Expect().Header("Content-Type").NotOneOf("application/json", "text/json"), // ) NotOneOf(values ...interface{}) IStep // Empty expects the specified header to be empty. // // Usage: // Expect().Headers().Empty() // Expect().Header("Content-Type").Empty() // // Example: // MustDo( // Get("https://example.com"), // Expect().Header("Content-Type").Empty(), // ) Empty() IStep // Len expects the specified header to be empty. // // Usage: // Expect().Header().Len(1) // Expect().Header("Content-Type").Len(16) // // Example: // MustDo( // Get("https://example.com"), // Expect().Header().Len(1), // Expect().Header("Content-Type").Len(16), // ) Len(size int) IStep // Equal expects the specified header to be equal the specified value. // // Usage: // Expect().Header().Equal(map[string]string{"Content-Type": "application/json"}) // Expect().Header("Content-Type").Equal("application/json") // Expect().Header("Content-Length").Equal(11) // // Example: // MustDo( // Get("https://example.com"), // Expect().Header("Content-Type").Equal("application/json"), // ) Equal(value interface{}) IStep // NotEqual expects the specified header to be equal the specified value. // // Usage: // Expect().Header().NotEqual(map[string]string{"Content-Type": "application/json"}) // Expect().Header("Content-Type").NotEqual("application/json") // Expect().Header("Content-Length").NotEqual(11) // // Example: // MustDo( // Get("https://example.com"), // Expect().Header("Content-Type").NotEqual("application/json"), // ) NotEqual(value interface{}) IStep }
IExpectHeader provides assertions on the http response header(s)
type IExpectStatus ¶
type IExpectStatus interface { IStep // Equal expects the status to be equal to the specified code. // // Usage: // Expect().Status().Equal(http.StatusOK) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().Equal(http.StatusOK), // ) Equal(statusCode int) IStep // NotEqual expects the status to be not equal to the specified code. // // Usage: // Expect().Status().NotEqual(http.StatusOK) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().NotEqual(http.StatusOK), // ) NotEqual(statusCode int) IStep // OneOf expects the status to be equal to one of the specified codes. // // Usage: // Expect().Status().OneOf(http.StatusOK, http.StatusNoContent) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().OneOf(http.StatusOK, http.StatusNoContent), // ) OneOf(statusCodes ...int) IStep // NotOneOf expects the status to be not equal to one of the specified codes. // // Usage: // Expect().Status().NotOneOf(http.StatusUnauthorized, http.StatusForbidden) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().NotOneOf(http.StatusUnauthorized, http.StatusForbidden), // ) NotOneOf(statusCodes ...int) IStep // GreaterThan expects the status to be not greater than the specified code. // // Usage: // Expect().Status().GreaterThan(http.StatusContinue) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().GreaterThan(http.StatusContinue), // ) GreaterThan(statusCode int) IStep // LessThan expects the status to be less than the specified code. // // Usage: // Expect().Status().LessThan(http.StatusInternalServerError) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().LessThan(http.StatusInternalServerError), // ) LessThan(statusCode int) IStep // GreaterOrEqualThan expects the status to be greater or equal than the specified code. // // Usage: // Expect().Status().GreaterOrEqualThan(http.StatusOK) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().GreaterOrEqualThan(http.StatusOK), // ) GreaterOrEqualThan(statusCode int) IStep // LessOrEqualThan expects the status to be less or equal than the specified code. // // Usage: // Expect().Status().LessOrEqualThan(http.StatusOK) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().LessOrEqualThan(http.StatusOK), // ) LessOrEqualThan(statusCode int) IStep // Between expects the status to be between the specified min and max value. (inclusive) // // Usage: // Expect().Status().Between(http.StatusOK, http.StatusAccepted) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().Between(http.StatusOK, http.StatusAccepted), // ) Between(min, max int) IStep // NotBetween expects the status to be not between the specified min and max value. (inclusive) // // Usage: // Expect().Status().NotBetween(http.StatusOK, http.StatusAccepted) // // Example: // MustDo( // Post("https://example.com"), // Expect().Status().NotBetween(http.StatusOK, http.StatusAccepted), // ) NotBetween(min, max int) IStep }
IExpectSpecificHeader provides assertions on the http response code
type ISend ¶
type ISend interface { IStep // Body sets the request body to the specified value. // // If you omit the argument you can fine tune the send value. // // Usage: // Send().Body("Hello World") // Send().Body().Interface("Hello World") // // Example: // MustDo( // Get("https://example.com"), // Send().Body("Hello World"), // ) Body(value ...interface{}) ISendBody // Interface sets the request body to the specified value. // // Usage: // Send().Interface("Hello World") // Send().Interface(map[string]interface{}{"Name": "Joe"}) // // Example: // MustDo( // Get("https://example.com"), // Send().Interface("Hello World"), // ) Interface(value interface{}) IStep // JSON sets the request body to the specified json value. // // Usage: // Send().JSON(map[string]interface{}{"Name": "Joe"}) // // Example: // MustDo( // Get("https://example.com"), // Send().JSON(map[string]interface{}{"Name": "Joe"}), // ) JSON(value interface{}) IStep // Header sets the specified request header to the specified value // // Usage: // Send().Header("Content-Type", "application/json") // // Example: // MustDo( // Get("https://example.com"), // Send().Header("Content-Type", "application/json"), // ) Header(name string, value interface{}) IStep // Custom can be used to send a custom behaviour. // // Example: // MustDo( // Get("https://example.com"), // Send().Custom(func(hit Hit) { // hit.Request().Body().SetString("Hello World") // }), // ) Custom(fn Callback) IStep }
type ISendBody ¶
type ISendBody interface { IStep // JSON sets the request body to the specified json value. // // Usage: // Send().Body().JSON(map[string]interface{}{"Name": "Joe"}) // // Example: // MustDo( // Get("https://example.com"), // Send().Body().JSON(map[string]interface{}{"Name": "Joe"}), // ) JSON(value interface{}) IStep // Interface sets the request body to the specified json value. // // Usage: // Send().Body().Interface("Hello World") // Send().Body().Interface(map[string]interface{}{"Name": "Joe"}) // // Example: // MustDo( // Get("https://example.com"), // Send().Body().Interface("Hello World"), // ) Interface(value interface{}) IStep }
type IStep ¶
type IStep interface {
// contains filtered or unexported methods
}
func BaseURL ¶
BaseURL sets the base url for each Connect, Delete, Get, Head, Post, Options, Put, Trace or Method
Examples:
MustDo( BaseURL("https://example.com") ) MustDo( BaseURL("https://%s/%s", "example.com", "index.html") )
func CombineSteps ¶
CombineSteps combines multiple steps to one
Example:
MustDo( Get("https://example.com"), CombineSteps( Expect().Status(http.StatusOK), Expect().Body("Hello World"), ), )
func Connect ¶
Connect creates a new Hit instance with CONNECT as the http makeMethodStep, use the optional arguments to format the url
Examples:
MustDo( Connect("https://example.com"), ) MustDo( Connect("https://%s/%s", "example.com", "index.html"), )
func Custom ¶
Custom can be used to run custom logic during various steps.
Example:
MustDo( Post("https://example.com"), Custom(ExpectStep, func(hit Hit) { if hit.Response().Body().String() != "Hello Earth" { panic("Expected Hello Earth") } }), )
func Debug ¶
Debug prints the current Request and Response to hit.Stdout(), you can filter the output based on expressions
Examples:
MustDo( Get("https://example.com"), Debug(), ) MustDo( Get("https://example.com"), Debug("Response.Headers"), )
func Delete ¶
Delete creates a new Hit instance with DELETE as the http makeMethodStep, use the optional arguments to format the url
Examples:
MustDo( Delete("https://example.com"), ) MustDo( Delete("https://%s/%s", "example.com", "index.html"), )
func Description ¶
Description sets a custom description for this test. The description will be printed in an error case
Example:
MustDo( Description("Check if example.com is available"), Get("https://example.com"), )
func Get ¶
Get creates a new Hit instance with GET as the http makeMethodStep, use the optional arguments to format the url
Examples:
MustDo( Get("https://example.com"), ) MustDo( Get("https://%s/%s", "example.com", "index.html"), )
func HTTPClient ¶
HTTPClient sets the client for the request
Example:
var client http.Client MustDo( Get("https://example.com"), HTTPClient(&client), )
func Head ¶
Head creates a new Hit instance with HEAD as the http makeMethodStep, use the optional arguments to format the url
Examples:
MustDo( Head("https://example.com"), ) MustDo( Head("https://%s/%s", "example.com", "index.html"), )
func Method ¶
Method creates a new Hit instance with the specified method and url
Examples:
MustDo( Method(http.MethodGet, "https://example.com"), ) MustDo( Method(http.MethodGet, "https://%s/%s", "example.com", "index.html"), )
func Options ¶
Options creates a new Hit instance with OPTIONS as the http makeMethodStep, use the optional arguments to format the url
Examples:
MustDo( Options("https://example.com"), ) MustDo( Options("https://%s/%s", "example.com", "index.html"), )
func Post ¶
Post creates a new Hit instance with POST as the http makeMethodStep, use the optional arguments to format the url
Examples:
MustDo( Post("https://example.com"), ) MustDo( Post("https://%s/%s", "example.com", "index.html"), )
func Put ¶
Put creates a new Hit instance with PUT as the http makeMethodStep, use the optional arguments to format the url
Examples:
MustDo( Put("https://example.com"), ) MustDo( Put("https://%s/%s", "example.com", "index.html"), )
func Request ¶
Request creates a new Hit instance with an existing http request
Example:
request, _ := http.NewRequest(http.MethodGet, "https://example.com", nil) MustDo( Request(request), )
Source Files ¶
- clear.go
- clear_expect.go
- clear_expect_body.go
- clear_expect_body_json.go
- clear_expect_header.go
- clear_expect_status.go
- clear_send.go
- clear_send_body.go
- clearpath.go
- converter.go
- debug.go
- expect.go
- expect_body.go
- expect_body_json.go
- expect_header.go
- expect_status.go
- hit.go
- http_body.go
- http_json.go
- http_request.go
- http_response.go
- other.go
- send.go
- send_body.go
- static.go
- step.go
- testingT.go