httpcheck: github.com/ivpusic/httpcheck Index | Files

package httpcheck

import "github.com/ivpusic/httpcheck"

Index

Package Files

closingbuffer.go httpcheck.go

type Callback Uses

type Callback func(*http.Response)

type Checker Uses

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

func New Uses

func New(t *testing.T, handler http.Handler) *Checker

func (*Checker) Cb Uses

func (c *Checker) Cb(cb Callback)

Will call provided callback function with current response

func (*Checker) Check Uses

func (c *Checker) Check() *Checker

Will make reqeust to built request object. After request is made, it will save response object for future assertions Responsibility of this method is also to start and stop HTTP server

func (*Checker) GetUrl Uses

func (c *Checker) GetUrl() string

func (*Checker) HasBody Uses

func (c *Checker) HasBody(body []byte) *Checker

Will check if body contains provided []byte data

func (*Checker) HasCookie Uses

func (c *Checker) HasCookie(key, expectedValue string) *Checker

Will put cookie on request

func (*Checker) HasHeader Uses

func (c *Checker) HasHeader(key, expectedValue string) *Checker

Will check if response contains header on provided key with provided value

func (*Checker) HasHeaders Uses

func (c *Checker) HasHeaders(headers map[string]string) *Checker

Will check if response contains a provided headers map

func (*Checker) HasJson Uses

func (c *Checker) HasJson(value interface{}) *Checker

Will ckeck if body contains json with provided value

func (*Checker) HasStatus Uses

func (c *Checker) HasStatus(status int) *Checker

Will ckeck if response status is equal to provided

func (*Checker) HasString Uses

func (c *Checker) HasString(body string) *Checker

Convenience wrapper for HasBody Checks if body is equal to the given string

func (*Checker) HasXml Uses

func (c *Checker) HasXml(value interface{}) *Checker

Will ckeck if body contains xml with provided value

func (*Checker) PersistCookie Uses

func (c *Checker) PersistCookie(cookie string)

enables a cookie to be preserved between requests

func (*Checker) SetTesting Uses

func (c *Checker) SetTesting(t *testing.T) *Checker

func (*Checker) Test Uses

func (c *Checker) Test(method, path string) *Checker

Prepare for testing some part of code which lives on provided path and method.

func (*Checker) TestRequest Uses

func (c *Checker) TestRequest(request *http.Request) *Checker

If you want to provide you custom http.Request instance, you can do it using this method In this case internal http.Request instance won't be created, and passed instane will be used for making request

func (*Checker) UnpersistCookie Uses

func (c *Checker) UnpersistCookie(cookie string)

the specified cookie will not be preserved during requests anymore

func (*Checker) WithBody Uses

func (c *Checker) WithBody(body []byte) *Checker

Adds the []byte data to the body

func (*Checker) WithCookie Uses

func (c *Checker) WithCookie(key, value string) *Checker

Will ckeck if response contains cookie with provided key and value

func (*Checker) WithHeader Uses

func (c *Checker) WithHeader(key, value string) *Checker

Will put header on request

func (*Checker) WithHeaders Uses

func (c *Checker) WithHeaders(headers map[string]string) *Checker

Will put a map of headers on request

func (*Checker) WithJson Uses

func (c *Checker) WithJson(value interface{}) *Checker

Will add the json-encoded struct to the body

func (*Checker) WithString Uses

func (c *Checker) WithString(body string) *Checker

Adds the string to the body

func (*Checker) WithXml Uses

func (c *Checker) WithXml(value interface{}) *Checker

Adds a XML encoded body to the request

Package httpcheck imports 12 packages (graph). Updated 2017-03-05. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).