hit

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 24 Imported by: 0

README

hit Travis Codecov GoDoc go-report

hit is an http integration test framework written in golang.

It is designed to be flexible as possible, but to keep a simple to use interface for developers.

So lets get started!

go get -u github.com/Eun/go-hit

import (
	"net/http"
	. "github.com/Eun/go-hit"
)

func TestHttpBin(t *testing.T) {
    Test(t,
        Description("Post to httpbin.org"),
        Get("https://httpbin.org/post"),
        Expect().Status(http.StatusMethodNotAllowed),
    )
}

expect, expect, expect, ....

Test(t,
    Get("https://httpbin.org/post"),
    Expect().Status(http.StatusMethodNotAllowed),
    Expect().Headers().Contains("Content-Type"),
    Expect().Body().Contains("Method Not Allowed"),
)

Sending some data

Test(t,
    Post("https://httpbin.org/post"),
    Send().Body("Hello HttpBin"),
    Expect().Status(http.StatusOK),
    Expect().Body().Contains("Hello HttpBin"), 
)
Sending and expecting JSON
Test(t,
    Post("https://httpbin.org/post"),
    Send().Headers().Set("Content-Type", "application/json"),
    Send().Body().JSON(map[string][]string{"Foo": []string{"Bar", "Baz"}}),
    Expect().Status(http.StatusOK),
    Expect().Body().JSON().Equal("json.Foo.1", "Baz"),
)

Problems? Debug!

Test(
    Post(t, "https://httpbin.org/post"),
    Debug(),
)

Twisted!

Although the following is hard to read it is possible to do!

Test(t,
    Post("https://httpbin.org/post"),
    Expect().Status(200),
    Send("Hello World"),
    Expect().Body().Contains("Hello"),
)

Custom Send and Expects

Test(t,
    Get("https://httpbin.org/get"),
    Send().Custom(func(hit Hit) {
        hit.Request().Body().SetStringf("Hello %s", "World")
    }),
    Expect().Custom(func(hit Hit) {
        if len(hit.Response().Body().String()) <= 0 {
            t.FailNow()
        }
    }),
    Custom(AfterExpectStep, func(Hit) {
        fmt.Println("everything done")
    }),
)

Templates / Multiuse

template := []IStep{
    Post("https://httpbin.org/post"),
    Send().Headers().Set("Content-Type", "application/json"),
    Expect().Headers("Content-Type").Equal("application/json"),
}
Test(t,
    append(template,
        Send().Body().JSON("Hello World"),
    )...,
)

Test(t,
    append(template,
        Send().Body().JSON("Hello Universe"),
    )...,
)

More examples can be found in the examples directory

Changelog
0.4.0
  • Fixed a double run bug in CombineSteps (#3)
  • Better Clear functionality, you can now clear any previous step by prepending Clear(), eg.
    Do(
        Get("https://example.com"),
        Expect().Body("Hello World"),
        Clear().Expect(),                        // remove all previous Expect() steps
        // Clear().Expect().Body("Hello World"), // remove only the Expect().Body("Hello World") step
    )
    
    // also works for CombineSteps
    Do(
        Post("https://example.com"),        
        CombineSteps(
            Send().Body("Hello World"),
            Expect().Body("Hello World"),
        ),
        Clear().Expect(),
    )
    
  • Simplified Expect().Header() use, no more Expect().Headers(), everything can now be done in the Expect().Header() function.
  • More documentation and examples
  • hit.Do and hit.MustDo for inline steps.
  • Removal of inline steps (use hit.Do and hit.MustDo)
    Do(
        Get("https://example.com"),
        Expect().Custon(func (hit Hit) {
            // Expect("Hello World") is invalid now
            // you must use MustDo() or Do()
            hit.MustDo(
                Expect("Hello World"),
            )
        }),
    )
    
  • hit.InsertSteps to insert steps during runtime

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(steps ...IStep) error

Do runs the specified steps and returns error if something was wrong

func MustDo

func MustDo(steps ...IStep)

MustDo runs the specified steps and panics with the error if something was wrong

func Test

func Test(t TestingT, steps ...IStep)

Test runs the specified steps and calls t.Error() if any error occurs during execution

Types

type Callback

type Callback func(hit Hit)

Callback will be used for Custom() functions

type HTTPBody

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

func (*HTTPBody) Bool

func (body *HTTPBody) Bool() bool

Bool returns the body as an bool

func (*HTTPBody) Bytes

func (body *HTTPBody) Bytes() []byte

Bytes returns the body as a byte slice

func (*HTTPBody) Float32

func (body *HTTPBody) Float32() float32

Float32 returns the body as an float32

func (*HTTPBody) Float64

func (body *HTTPBody) Float64() float64

Float64 returns the body as an float64

func (*HTTPBody) Int

func (body *HTTPBody) Int() int

Int returns the body as an int

func (*HTTPBody) Int16

func (body *HTTPBody) Int16() int16

Int16 returns the body as an int16

func (*HTTPBody) Int32

func (body *HTTPBody) Int32() int32

Int32 returns the body as an int64

func (*HTTPBody) Int64

func (body *HTTPBody) Int64() int64

Int64 returns the body as an int64

func (*HTTPBody) Int8

func (body *HTTPBody) Int8() int8

Int8 returns the body as an int8

func (*HTTPBody) JSON

func (body *HTTPBody) JSON() *HTTPJson

JSON returns the body as an jso

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) SetBool

func (body *HTTPBody) SetBool(b bool)

SetBool sets the body to the specified bool

func (*HTTPBody) SetBytes

func (body *HTTPBody) SetBytes(b []byte)

SetString sets the body to the specified byte slice

func (*HTTPBody) SetFloat32

func (body *HTTPBody) SetFloat32(f float32)

SetFloat32 sets the body to the specified float32

func (*HTTPBody) SetFloat64

func (body *HTTPBody) SetFloat64(f float64)

SetFloat64 sets the body to the specified float64

func (*HTTPBody) SetInt

func (body *HTTPBody) SetInt(i int)

SetInt sets the body to the specified int

func (*HTTPBody) SetInt16

func (body *HTTPBody) SetInt16(i int16)

SetInt16 sets the body to the specified int16

func (*HTTPBody) SetInt32

func (body *HTTPBody) SetInt32(i int32)

SetInt32 sets the body to the specified int64

func (*HTTPBody) SetInt64

func (body *HTTPBody) SetInt64(i int64)

SetInt64 sets the body to the specified int64

func (*HTTPBody) SetInt8

func (body *HTTPBody) SetInt8(i int8)

SetInt8 sets the body to the specified int8

func (*HTTPBody) SetReader

func (body *HTTPBody) SetReader(r io.Reader)

setters SetReader sets the body to the contents of the specified reader

func (*HTTPBody) SetString

func (body *HTTPBody) SetString(s string)

SetString sets the body to the specified string

func (*HTTPBody) SetStringf

func (body *HTTPBody) SetStringf(format string, a ...interface{})

SetStringf sets the body to the specified string format

func (*HTTPBody) SetUint

func (body *HTTPBody) SetUint(i uint)

SetUint sets the body to the specified int

func (*HTTPBody) SetUint16

func (body *HTTPBody) SetUint16(i uint16)

SetUint16 sets the body to the specified uint16

func (*HTTPBody) SetUint32

func (body *HTTPBody) SetUint32(i uint32)

SetUint32 sets the body to the specified uint64

func (*HTTPBody) SetUint64

func (body *HTTPBody) SetUint64(i uint64)

SetUint64 sets the body to the specified uint64

func (*HTTPBody) SetUint8

func (body *HTTPBody) SetUint8(i uint8)

SetUint8 sets the body to the specified uint8

func (*HTTPBody) String

func (body *HTTPBody) String() string

String returns the body as a string

func (*HTTPBody) Uint

func (body *HTTPBody) Uint() uint

Uint returns the body as an uint

func (*HTTPBody) Uint16

func (body *HTTPBody) Uint16() uint16

Uint16 returns the body as an uint16

func (*HTTPBody) Uint32

func (body *HTTPBody) Uint32() uint32

Uint32 returns the body as an uint64

func (*HTTPBody) Uint64

func (body *HTTPBody) Uint64() uint64

Uint64 returns the body as an uint64

func (*HTTPBody) Uint8

func (body *HTTPBody) Uint8() uint8

Uint8 returns the body as an uint8

type HTTPJson

type HTTPJson struct {
	Hit
	// contains filtered or unexported fields
}

func (*HTTPJson) Get

func (jsn *HTTPJson) Get(expression string) interface{}

Get returns the body as an interface type based on the underlying data

func (*HTTPJson) GetAs

func (jsn *HTTPJson) GetAs(expression string, container interface{}) interface{}

GetAs returns the body as the specified interface type

func (*HTTPJson) Set

func (jsn *HTTPJson) Set(data interface{})

Set sets the body to the specified json data

type HTTPRequest

type HTTPRequest struct {
	Hit Hit
	*http.Request
	// contains filtered or unexported fields
}

func (*HTTPRequest) Body

func (req *HTTPRequest) Body() *HTTPBody

type HTTPResponse

type HTTPResponse struct {
	Hit Hit
	*http.Response
	// contains filtered or unexported fields
}

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

func Expect

func Expect(data ...interface{}) IExpect

Expect expects the body to be equal the specified value, omit the parameter to get more options

Examples:

MustDo(
    Get("https://example.com"),
    Expect().Body().Contains("Hello World")
)

MustDo(
    Get("https://example.com"),
    Expect("Hello World"),
)

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
}

func Send

func Send(data ...interface{}) ISend

Send sends the specified data as the body payload

Examples:

MustDo(
    Post("https://example.com"),
    Send("Hello World"),
)

MustDo(
    Post("https://example.com"),
    Send().Body("Hello World")
)

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

func BaseURL(url string, a ...interface{}) IStep

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

func CombineSteps(steps ...IStep) IStep

CombineSteps combines multiple steps to one

Example:

MustDo(
    Get("https://example.com"),
    CombineSteps(
       Expect().Status(http.StatusOK),
       Expect().Body("Hello World"),
    ),
)

func Connect

func Connect(url string, a ...interface{}) IStep

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

func Custom(when StepTime, exec Callback) IStep

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

func Debug(expression ...string) IStep

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

func Delete(url string, a ...interface{}) IStep

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

func Description(description string) IStep

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

func Get(url string, a ...interface{}) IStep

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

func HTTPClient(client *http.Client) IStep

HTTPClient sets the client for the request

Example:

var client http.Client
MustDo(
    Get("https://example.com"),
    HTTPClient(&client),
)
func Head(url string, a ...interface{}) IStep

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

func Method(method, url string, a ...interface{}) IStep

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

func Options(url string, a ...interface{}) IStep

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

func Post(url string, a ...interface{}) IStep

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

func Put(url string, a ...interface{}) IStep

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

func Request(request *http.Request) IStep

Request creates a new Hit instance with an existing http request

Example:

request, _ := http.NewRequest(http.MethodGet, "https://example.com", nil)
MustDo(
    Request(request),
)

func Stdout

func Stdout(w io.Writer) IStep

Stdout sets the output to the specified writer

Example:

MustDo(
    Get("https://example.com"),
    Stdout(os.Stderr),
    Debug(),
)

func Trace

func Trace(url string, a ...interface{}) IStep

Trace creates a new Hit instance with TRACE as the http makeMethodStep, use the optional arguments to format the url

Examples:

MustDo(
    Trace("https://example.com"),
)

MustDo(
    Trace("https://%s/%s", "example.com", "index.html"),
)

type PanicT

type PanicT struct{}

func (PanicT) Error

func (PanicT) Error(args ...interface{})

type StepTime

type StepTime uint8
const (
	CombineStep StepTime = iota + 1
	CleanStep
	BeforeSendStep
	SendStep
	AfterSendStep
	BeforeExpectStep
	ExpectStep
	AfterExpectStep
)

func (StepTime) String

func (s StepTime) String() string

type TestingT

type TestingT interface {
	FailNow()
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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