htest

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 15 Imported by: 0

README

htest is a http-test package

Coverage Status Go Report Card Build Status Documentation

Table of Contents

Basic Usage


Test MockServer

Test a Handler or a HandlerFunc

Test HandlerFunc
// example/basic_mock_client.go
package myapp

import (
	"io"
	"net/http"
)

func NameHandler(w http.ResponseWriter, req *http.Request) {
	io.WriteString(w, `{"name": "hexi"}`)
}
// example/basic_mock_client_test.go
package myapp

import (
	"testing"
	"github.com/Hexilee/htest"
)

func TestNameHandlerFunc(t *testing.T) {
	htest.NewClient(t).
		ToFunc(NameHandler).
		Get("").
		Test().
		StatusOK().
		JSON().
		String("name", "hexi")
}

You can also test handler (*http.ServeMux, *echo.Echo .etc.)

To ServeMux
// example/basic_mock_client.go
package myapp

import (
	"io"
	"net/http"
)

var (
	Mux *http.ServeMux
)

func init() {
	Mux = http.NewServeMux()
	Mux.HandleFunc("/name", NameHandler)
}

func NameHandler(w http.ResponseWriter, req *http.Request) {
	io.WriteString(w, `{"name": "hexi"}`)
}
// example/basic_mock_client_test.go
package myapp

import (
	"testing"
	"github.com/Hexilee/htest"
)

func TestNameHandler(t *testing.T) {
	htest.NewClient(t).
		To(Mux).
		Get("/name").
		Test().
		StatusOK().
		JSON().
		String("name", "hexi")
}
To Echo
// example/basic_mock_client.go
package myapp

import (
	"io"
	"github.com/labstack/echo"
)

var (
	server *echo.Echo
)

func init() {
	server = echo.New()
	server.GET("/name", NameHandlerEcho)
}

func NameHandlerEcho(c echo.Context) error {
	return c.String(http.StatusOK, `{"name": "hexi"}`)
}
// example/basic_mock_client_test.go
package myapp

import (
	"testing"
	"github.com/Hexilee/htest"
)

func TestNameHandlerEcho(t *testing.T) {
	htest.NewClient(t).
		To(server).
		Get("/name").
		Test().
		StatusOK().
		JSON().
		String("name", "hexi")
}
Test RealServer

Send a http request and test the response

Github API
// request_test.go
func TestRequest_Send(t *testing.T) {
	NewClient(t).
		Get("https://api.github.com/users/Hexilee").
		Send().
		StatusOK().
		JSON().
		String("login", "Hexilee")
}

Client


Set MockServer

Set mock server to be tested (Do not need it when you test real server)

HandlerFunc

Set a HandlerFunc as mock server

// example/basic_mock_client_test.go
package myapp

import (
	"testing"
	"github.com/Hexilee/htest"
)

func TestNameHandlerFunc(t *testing.T) {
	htest.NewClient(t).
		ToFunc(NameHandler).
		Get("").
		Test().
		StatusOK().
		JSON().
		String("name", "hexi")
}
Handler

Set a Handler as mock server

// example/basic_mock_client_test.go
package myapp

import (
	"testing"
	"github.com/Hexilee/htest"
)

func TestNameHandler(t *testing.T) {
	htest.NewClient(t).
		To(Mux).
		Get("/name").
		Test().
		StatusOK().
		JSON().
		String("name", "hexi")
}
Construct Request

Construct htest.Request using different http methods

Http Methods

For example

  • Get
// client.go
func (c Client) Get(path string) *Request

More

  • Head
  • Trace
  • Options
  • Connect
  • Delete
  • Post
  • Put
  • Patch

Request


Set Headers

Set headers and return *Request for chaining-call

  • SetHeader
// server_test.go

Mux.Get("/request/header", HeaderHandler)

// request_test.go

func HeaderHandler(w http.ResponseWriter, req *http.Request) {
	if req.Header.Get(HeaderContentType) == MIMEApplicationJSON {
		io.WriteString(w, `{"result": "JSON"}`)
		return
	}
	http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
}

func TestRequest_SetHeader(t *testing.T) {
	client := NewClient(t).To(Mux)
	// bad content type
	client.
		Get("/request/header").
		SetHeader(HeaderContentType, MIMEApplicationForm).
		Test().
		StatusBadRequest()

	// right
	client.
		Get("/request/header").
		SetHeader(HeaderContentType, MIMEApplicationJSON).
		Test().
		StatusOK().
		JSON().
		String("result", "JSON")
}

HeaderContentType, MIMEApplicationForm are constants in const.go For more information, you can refer to Appendix

  • SetHeaders
// request_test.go

func TestRequest_SetHeaders(t *testing.T) {
	client := NewClient(t).To(Mux)
	// bad content type
	client.Get("/request/header").
		SetHeaders(
			map[string]string{
				HeaderContentType: MIMEApplicationForm,
			},
		).
		Test().
		StatusBadRequest()

	// right
	client.Get("/request/header").
		SetHeaders(
			map[string]string{
				HeaderContentType: MIMEApplicationJSON,
			},
		).
		Test().
		StatusOK().
		JSON().
		String("result", "JSON")
}

Add cookie and return *Request for chaining-call

// server_test.go

Mux.Get("/request/cookie", CookieHandler)

// request_test.go

var (
	testCookie = http.Cookie{Name: "test_cookie", Value: "cookie_value"}
)

func CookieHandler(w http.ResponseWriter, req *http.Request) {
	cookie, err := req.Cookie(testCookie.Name)
	if err != nil {
		http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
		return
	}
	io.WriteString(w, fmt.Sprintf(`{"cookie": "%s"}`, cookie))
}


func TestRequest_AddCookie(t *testing.T) {
	client := NewClient(t).
		To(Mux)
	client.
		Get("/request/cookie").
		Test().
		StatusForbidden()
	client.
		Get("/request/cookie").
		AddCookie(&testCookie).
		Test().
		StatusOK().
		JSON().
		String("cookie", testCookie.String())
}
Test

Calling *Request.Test will test the mock server You must have called Client.To or Client.ToFunc, otherwise causing a panic (htest.MockNilError)

Send
As http.Request

Response


Assert StatusCode
Code
StatusXXX
Assert Headers
Headers
HeaderXXX
Assert Body
Get Body
Body Types
As http.Response

Body

JSON
XML
MD5
SHA1

Appendix

Documentation

Overview

htest is a http test package

import "github.com/zhwei820/htest"

Index

Constants

View Source
const (
	CONNECT = "CONNECT"
	DELETE  = "DELETE"
	GET     = "GET"
	HEAD    = "HEAD"
	OPTIONS = "OPTIONS"
	PATCH   = "PATCH"
	POST    = "POST"
	PUT     = "PUT"
	TRACE   = "TRACE"
)

HTTP methods

View Source
const (
	MIMEApplicationJSON                  = "application/json"
	MIMEApplicationJSONCharsetUTF8       = MIMEApplicationJSON + "; " + charsetUTF8
	MIMEApplicationJavaScript            = "application/javascript"
	MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8
	MIMEApplicationXML                   = "application/xml"
	MIMEApplicationXMLCharsetUTF8        = MIMEApplicationXML + "; " + charsetUTF8
	MIMETextXML                          = "text/xml"
	MIMETextXMLCharsetUTF8               = MIMETextXML + "; " + charsetUTF8
	MIMEApplicationForm                  = "application/x-www-form-urlencoded"
	MIMEApplicationProtobuf              = "application/protobuf"
	MIMEApplicationMsgpack               = "application/msgpack"
	MIMETextHTML                         = "text/html"
	MIMETextHTMLCharsetUTF8              = MIMETextHTML + "; " + charsetUTF8
	MIMETextPlain                        = "text/plain"
	MIMETextPlainCharsetUTF8             = MIMETextPlain + "; " + charsetUTF8
	MIMEMultipartForm                    = "multipart/form-data"
	MIMEOctetStream                      = "application/octet-stream"
)

MIME types

View Source
const (
	HeaderAccept              = "Accept"
	HeaderAcceptEncoding      = "Accept-Encoding"
	HeaderAllow               = "Allow"
	HeaderAuthorization       = "Authorization"
	HeaderContentDisposition  = "Content-Disposition"
	HeaderContentEncoding     = "Content-Encoding"
	HeaderContentLength       = "Content-Length"
	HeaderContentType         = "Content-Type"
	HeaderCookie              = "Cookie"
	HeaderSetCookie           = "Set-Cookie"
	HeaderIfModifiedSince     = "If-Modified-Since"
	HeaderLastModified        = "Last-Modified"
	HeaderLocation            = "Location"
	HeaderUpgrade             = "Upgrade"
	HeaderVary                = "Vary"
	HeaderWWWAuthenticate     = "WWW-Authenticate"
	HeaderXForwardedFor       = "X-Forwarded-For"
	HeaderXForwardedProto     = "X-Forwarded-Proto"
	HeaderXForwardedProtocol  = "X-Forwarded-Protocol"
	HeaderXForwardedSsl       = "X-Forwarded-Ssl"
	HeaderXUrlScheme          = "X-Url-Scheme"
	HeaderXHTTPMethodOverride = "X-HTTP-Method-Override"
	HeaderXRealIP             = "X-Real-IP"
	HeaderXRequestID          = "X-Request-ID"
	HeaderServer              = "Server"
	HeaderOrigin              = "Origin"

	// Access control
	HeaderAccessControlRequestMethod    = "Access-Control-Request-Method"
	HeaderAccessControlRequestHeaders   = "Access-Control-Request-Headers"
	HeaderAccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	HeaderAccessControlAllowMethods     = "Access-Control-Allow-Methods"
	HeaderAccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	HeaderAccessControlExposeHeaders    = "Access-Control-Expose-Headers"
	HeaderAccessControlMaxAge           = "Access-Control-Max-Age"

	// Security
	HeaderStrictTransportSecurity = "Strict-Transport-Security"
	HeaderXContentTypeOptions     = "X-Content-Type-Options"
	HeaderXXSSProtection          = "X-XSS-Protection"
	HeaderXFrameOptions           = "X-Frame-Options"
	HeaderContentSecurityPolicy   = "Content-Security-Policy"
	HeaderXCSRFToken              = "X-CSRF-Token"
)

Headers

View Source
const (
	MockNilError = "Request.Handler cannot be nil, had you called Client.To or Client.ToFunc?"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*testing.T
	// contains filtered or unexported fields
}

func NewClient

func NewClient(t *testing.T) *Client

func (Client) Connect added in v0.2.0

func (c Client) Connect(path string, body ...io.Reader) *Request

func (Client) Delete added in v0.2.0

func (c Client) Delete(path string, body ...io.Reader) *Request

func (Client) Get

func (c Client) Get(path string, body ...io.Reader) *Request

func (Client) Head added in v0.2.0

func (c Client) Head(path string, body ...io.Reader) *Request

func (Client) NewRequest

func (c Client) NewRequest(req *http.Request) *Request

func (Client) Options added in v0.2.0

func (c Client) Options(path string, body ...io.Reader) *Request

func (Client) Patch added in v0.2.0

func (c Client) Patch(path string, body io.Reader) *Request

func (Client) Post added in v0.2.0

func (c Client) Post(path string, body io.Reader) *Request

func (Client) Put added in v0.2.0

func (c Client) Put(path string, body io.Reader) *Request

func (Client) To

func (c Client) To(handler http.Handler) *Client

func (Client) ToFunc

func (c Client) ToFunc(handlerFunc http.HandlerFunc) *Client

func (Client) Trace added in v0.2.0

func (c Client) Trace(path string, body ...io.Reader) *Request

type JSON

type JSON struct {
	*testing.T
	// contains filtered or unexported fields
}

func NewJSON

func NewJSON(body []byte, t *testing.T) *JSON

func (*JSON) Bind

func (j *JSON) Bind(obj interface{}) error

func (*JSON) Body added in v0.5.1

func (j *JSON) Body() []byte

func (*JSON) Dump added in v1.2.0

func (j *JSON) Dump()

func (*JSON) Empty added in v0.5.1

func (j *JSON) Empty() *JSON

func (*JSON) Exist

func (j *JSON) Exist(key string) *JSON

func (*JSON) False added in v0.5.1

func (j *JSON) False(key string) *JSON

func (*JSON) Float added in v0.5.1

func (j *JSON) Float(key string, expect float64) *JSON

func (*JSON) GetKey added in v0.5.1

func (j *JSON) GetKey(key string) (result gjson.Result, exist bool)

func (*JSON) Int added in v0.5.1

func (j *JSON) Int(key string, expect int64) *JSON

func (*JSON) NotEmpty added in v0.5.1

func (j *JSON) NotEmpty() *JSON

func (*JSON) NotExist

func (j *JSON) NotExist(key string) *JSON

func (*JSON) String

func (j *JSON) String(key, expect string) *JSON

func (*JSON) Time added in v0.5.1

func (j *JSON) Time(key string, expect time.Time) *JSON

func (*JSON) True added in v0.5.1

func (j *JSON) True(key string) *JSON

func (*JSON) Uint added in v0.5.1

func (j *JSON) Uint(key string, expect uint64) *JSON

type MD5 added in v0.6.0

type MD5 struct {
	*testing.T
	// contains filtered or unexported fields
}

func NewMD5 added in v0.6.0

func NewMD5(body []byte, t *testing.T) *MD5

func (*MD5) Body added in v0.6.0

func (m *MD5) Body() []byte

func (*MD5) Expect added in v0.6.0

func (m *MD5) Expect(expect string) *MD5

type Request

type Request struct {
	*http.Request
	Handler http.Handler
	*testing.T
}

func (*Request) AddCookie added in v1.0.0

func (r *Request) AddCookie(cookie *http.Cookie) *Request

func (*Request) Send

func (r *Request) Send() *Response

func (*Request) SetHeader

func (r *Request) SetHeader(key, value string) *Request

func (*Request) SetHeaders

func (r *Request) SetHeaders(headers map[string]string) *Request

func (*Request) Test added in v1.0.0

func (r *Request) Test() *Response

type Response

type Response struct {
	*http.Response
	*testing.T
}

func NewResponse

func NewResponse(response *http.Response, t *testing.T) *Response

func (*Response) Bind

func (r *Response) Bind(obj interface{}) error

func (*Response) Bytes

func (r *Response) Bytes() []byte

func (*Response) Code added in v0.4.0

func (r *Response) Code(statusCode int) *Response

func (*Response) Expect added in v0.6.0

func (r *Response) Expect(expect string)

func (*Response) HeaderAccept added in v0.5.0

func (r *Response) HeaderAccept(expect string) *Response

func (*Response) HeaderAcceptEncoding added in v0.5.0

func (r *Response) HeaderAcceptEncoding(expect string) *Response

func (*Response) HeaderAccessControlAllowCredentials added in v0.5.0

func (r *Response) HeaderAccessControlAllowCredentials(expect string) *Response

func (*Response) HeaderAccessControlAllowHeaders added in v0.5.0

func (r *Response) HeaderAccessControlAllowHeaders(expect string) *Response

func (*Response) HeaderAccessControlAllowMethods added in v0.5.0

func (r *Response) HeaderAccessControlAllowMethods(expect string) *Response

func (*Response) HeaderAccessControlAllowOrigin added in v0.5.0

func (r *Response) HeaderAccessControlAllowOrigin(expect string) *Response

func (*Response) HeaderAccessControlExposeHeaders added in v0.5.0

func (r *Response) HeaderAccessControlExposeHeaders(expect string) *Response

func (*Response) HeaderAccessControlMaxAge added in v0.5.0

func (r *Response) HeaderAccessControlMaxAge(expect string) *Response

func (*Response) HeaderAccessControlRequestHeaders added in v0.5.0

func (r *Response) HeaderAccessControlRequestHeaders(expect string) *Response

func (*Response) HeaderAccessControlRequestMethod added in v0.5.0

func (r *Response) HeaderAccessControlRequestMethod(expect string) *Response

func (*Response) HeaderAllow added in v0.5.0

func (r *Response) HeaderAllow(expect string) *Response

func (*Response) HeaderAuthorization added in v0.5.0

func (r *Response) HeaderAuthorization(expect string) *Response

func (*Response) HeaderContentDisposition added in v0.5.0

func (r *Response) HeaderContentDisposition(expect string) *Response

func (*Response) HeaderContentEncoding added in v0.5.0

func (r *Response) HeaderContentEncoding(expect string) *Response

func (*Response) HeaderContentLength added in v0.5.0

func (r *Response) HeaderContentLength(expect string) *Response

func (*Response) HeaderContentSecurityPolicy added in v0.5.0

func (r *Response) HeaderContentSecurityPolicy(expect string) *Response

func (*Response) HeaderContentType added in v0.5.0

func (r *Response) HeaderContentType(expect string) *Response

func (*Response) HeaderCookie added in v0.5.0

func (r *Response) HeaderCookie(expect string) *Response

func (*Response) HeaderIfModifiedSince added in v0.5.0

func (r *Response) HeaderIfModifiedSince(expect string) *Response

func (*Response) HeaderLastModified added in v0.5.0

func (r *Response) HeaderLastModified(expect string) *Response

func (*Response) HeaderLocation added in v0.5.0

func (r *Response) HeaderLocation(expect string) *Response

func (*Response) HeaderOrigin added in v0.5.0

func (r *Response) HeaderOrigin(expect string) *Response

func (*Response) HeaderServer added in v0.5.0

func (r *Response) HeaderServer(expect string) *Response

func (*Response) HeaderSetCookie added in v0.5.0

func (r *Response) HeaderSetCookie(expect string) *Response

func (*Response) HeaderStrictTransportSecurity added in v0.5.0

func (r *Response) HeaderStrictTransportSecurity(expect string) *Response

func (*Response) HeaderUpgrade added in v0.5.0

func (r *Response) HeaderUpgrade(expect string) *Response

func (*Response) HeaderVary added in v0.5.0

func (r *Response) HeaderVary(expect string) *Response

func (*Response) HeaderWWWAuthenticate added in v0.5.0

func (r *Response) HeaderWWWAuthenticate(expect string) *Response

func (*Response) HeaderXCSRFToken added in v0.5.0

func (r *Response) HeaderXCSRFToken(expect string) *Response

func (*Response) HeaderXContentTypeOptions added in v0.5.0

func (r *Response) HeaderXContentTypeOptions(expect string) *Response

func (*Response) HeaderXForwardedFor added in v0.5.0

func (r *Response) HeaderXForwardedFor(expect string) *Response

func (*Response) HeaderXForwardedProto added in v0.5.0

func (r *Response) HeaderXForwardedProto(expect string) *Response

func (*Response) HeaderXForwardedProtocol added in v0.5.0

func (r *Response) HeaderXForwardedProtocol(expect string) *Response

func (*Response) HeaderXForwardedSsl added in v0.5.0

func (r *Response) HeaderXForwardedSsl(expect string) *Response

func (*Response) HeaderXFrameOptions added in v0.5.0

func (r *Response) HeaderXFrameOptions(expect string) *Response

func (*Response) HeaderXHTTPMethodOverride added in v0.5.0

func (r *Response) HeaderXHTTPMethodOverride(expect string) *Response

func (*Response) HeaderXRealIP added in v0.5.0

func (r *Response) HeaderXRealIP(expect string) *Response

func (*Response) HeaderXRequestID added in v0.5.0

func (r *Response) HeaderXRequestID(expect string) *Response

func (*Response) HeaderXUrlScheme added in v0.5.0

func (r *Response) HeaderXUrlScheme(expect string) *Response

func (*Response) HeaderXXSSProtection added in v0.5.0

func (r *Response) HeaderXXSSProtection(expect string) *Response

func (*Response) Headers added in v0.5.0

func (r *Response) Headers(key, expect string) *Response

func (*Response) JSON

func (r *Response) JSON() *JSON

func (*Response) MD5 added in v0.6.0

func (r *Response) MD5() *MD5

func (*Response) SHA1 added in v0.6.0

func (r *Response) SHA1() *SHA1

func (*Response) StatusAccepted added in v0.4.0

func (r *Response) StatusAccepted() *Response

func (*Response) StatusAlreadyReported added in v0.4.0

func (r *Response) StatusAlreadyReported() *Response

func (*Response) StatusBadGateway added in v0.4.0

func (r *Response) StatusBadGateway() *Response

func (*Response) StatusBadRequest added in v0.4.0

func (r *Response) StatusBadRequest() *Response

func (*Response) StatusConflict added in v0.4.0

func (r *Response) StatusConflict() *Response

func (*Response) StatusContinue added in v0.4.0

func (r *Response) StatusContinue() *Response

func (*Response) StatusCreated added in v0.4.0

func (r *Response) StatusCreated() *Response

func (*Response) StatusExpectationFailed added in v0.4.0

func (r *Response) StatusExpectationFailed() *Response

func (*Response) StatusFailedDependency added in v0.4.0

func (r *Response) StatusFailedDependency() *Response

func (*Response) StatusForbidden added in v0.4.0

func (r *Response) StatusForbidden() *Response

func (*Response) StatusFound added in v0.4.0

func (r *Response) StatusFound() *Response

func (*Response) StatusGatewayTimeout added in v0.4.0

func (r *Response) StatusGatewayTimeout() *Response

func (*Response) StatusGone added in v0.4.0

func (r *Response) StatusGone() *Response

func (*Response) StatusHTTPVersionNotSupported added in v0.4.0

func (r *Response) StatusHTTPVersionNotSupported() *Response

func (*Response) StatusIMUsed added in v0.4.0

func (r *Response) StatusIMUsed() *Response

func (*Response) StatusInsufficientStorage added in v0.4.0

func (r *Response) StatusInsufficientStorage() *Response

func (*Response) StatusInternalServerError added in v0.4.0

func (r *Response) StatusInternalServerError() *Response

func (*Response) StatusLengthRequired added in v0.4.0

func (r *Response) StatusLengthRequired() *Response

func (*Response) StatusLocked added in v0.4.0

func (r *Response) StatusLocked() *Response

func (*Response) StatusLoopDetected added in v0.4.0

func (r *Response) StatusLoopDetected() *Response

func (*Response) StatusMethodNotAllowed added in v0.4.0

func (r *Response) StatusMethodNotAllowed() *Response

func (*Response) StatusMovedPermanently added in v0.4.0

func (r *Response) StatusMovedPermanently() *Response

func (*Response) StatusMultiStatus added in v0.4.0

func (r *Response) StatusMultiStatus() *Response

func (*Response) StatusMultipleChoices added in v0.4.0

func (r *Response) StatusMultipleChoices() *Response

func (*Response) StatusNetworkAuthenticationRequired added in v0.4.0

func (r *Response) StatusNetworkAuthenticationRequired() *Response

func (*Response) StatusNoContent added in v0.4.0

func (r *Response) StatusNoContent() *Response

func (*Response) StatusNonAuthoritativeInfo added in v0.4.0

func (r *Response) StatusNonAuthoritativeInfo() *Response

func (*Response) StatusNotAcceptable added in v0.4.0

func (r *Response) StatusNotAcceptable() *Response

func (*Response) StatusNotExtended added in v0.4.0

func (r *Response) StatusNotExtended() *Response

func (*Response) StatusNotFound added in v0.4.0

func (r *Response) StatusNotFound() *Response

func (*Response) StatusNotImplemented added in v0.4.0

func (r *Response) StatusNotImplemented() *Response

func (*Response) StatusNotModified added in v0.4.0

func (r *Response) StatusNotModified() *Response

func (*Response) StatusOK added in v0.4.0

func (r *Response) StatusOK() *Response

func (*Response) StatusPartialContent added in v0.4.0

func (r *Response) StatusPartialContent() *Response

func (*Response) StatusPaymentRequired added in v0.4.0

func (r *Response) StatusPaymentRequired() *Response

func (*Response) StatusPermanentRedirect added in v0.4.0

func (r *Response) StatusPermanentRedirect() *Response

func (*Response) StatusPreconditionFailed added in v0.4.0

func (r *Response) StatusPreconditionFailed() *Response

func (*Response) StatusPreconditionRequired added in v0.4.0

func (r *Response) StatusPreconditionRequired() *Response

func (*Response) StatusProcessing added in v0.4.0

func (r *Response) StatusProcessing() *Response

func (*Response) StatusProxyAuthRequired added in v0.4.0

func (r *Response) StatusProxyAuthRequired() *Response

func (*Response) StatusRequestEntityTooLarge added in v0.4.0

func (r *Response) StatusRequestEntityTooLarge() *Response

func (*Response) StatusRequestHeaderFieldsTooLarge added in v0.4.0

func (r *Response) StatusRequestHeaderFieldsTooLarge() *Response

func (*Response) StatusRequestTimeout added in v0.4.0

func (r *Response) StatusRequestTimeout() *Response

func (*Response) StatusRequestURITooLong added in v0.4.0

func (r *Response) StatusRequestURITooLong() *Response

func (*Response) StatusRequestedRangeNotSatisfiable added in v0.4.0

func (r *Response) StatusRequestedRangeNotSatisfiable() *Response

func (*Response) StatusResetContent added in v0.4.0

func (r *Response) StatusResetContent() *Response

func (*Response) StatusSeeOther added in v0.4.0

func (r *Response) StatusSeeOther() *Response

func (*Response) StatusServiceUnavailable added in v0.4.0

func (r *Response) StatusServiceUnavailable() *Response

func (*Response) StatusSwitchingProtocols added in v0.4.0

func (r *Response) StatusSwitchingProtocols() *Response

func (*Response) StatusTeapot added in v0.4.0

func (r *Response) StatusTeapot() *Response

func (*Response) StatusTemporaryRedirect added in v0.4.0

func (r *Response) StatusTemporaryRedirect() *Response

func (*Response) StatusTooManyRequests added in v0.4.0

func (r *Response) StatusTooManyRequests() *Response

func (*Response) StatusUnauthorized added in v0.4.0

func (r *Response) StatusUnauthorized() *Response

func (*Response) StatusUnavailableForLegalReasons added in v0.4.0

func (r *Response) StatusUnavailableForLegalReasons() *Response

func (*Response) StatusUnprocessableEntity added in v0.4.0

func (r *Response) StatusUnprocessableEntity() *Response

func (*Response) StatusUnsupportedMediaType added in v0.4.0

func (r *Response) StatusUnsupportedMediaType() *Response

func (*Response) StatusUpgradeRequired added in v0.4.0

func (r *Response) StatusUpgradeRequired() *Response

func (*Response) StatusUseProxy added in v0.4.0

func (r *Response) StatusUseProxy() *Response

func (*Response) StatusVariantAlsoNegotiates added in v0.4.0

func (r *Response) StatusVariantAlsoNegotiates() *Response

func (*Response) String

func (r *Response) String() string

func (*Response) XML added in v0.5.1

func (r *Response) XML() *XML

type SHA1 added in v0.6.0

type SHA1 struct {
	*testing.T
	// contains filtered or unexported fields
}

func NewSHA1 added in v0.6.0

func NewSHA1(body []byte, t *testing.T) *SHA1

func (*SHA1) Body added in v0.6.0

func (s *SHA1) Body() []byte

func (*SHA1) Expect added in v0.6.0

func (s *SHA1) Expect(expect string) *SHA1

type XML added in v0.5.1

type XML struct {
	*JSON
	// contains filtered or unexported fields
}

func NewXML added in v0.5.1

func NewXML(body []byte, t *testing.T) *XML

func (*XML) Bind added in v0.5.1

func (x *XML) Bind(obj interface{}) error

func (*XML) Body added in v0.5.1

func (x *XML) Body() []byte

func (*XML) Empty added in v0.5.1

func (x *XML) Empty() *XML

func (*XML) Exist added in v0.5.1

func (x *XML) Exist(key string) *XML

func (*XML) False added in v1.0.0

func (x *XML) False(key string) *XML

func (*XML) Float added in v1.0.0

func (x *XML) Float(key string, expect float64) *XML

func (*XML) Int added in v1.0.0

func (x *XML) Int(key string, expect int64) *XML

func (*XML) NotEmpty added in v0.5.1

func (x *XML) NotEmpty() *XML

func (*XML) NotExist added in v0.5.1

func (x *XML) NotExist(key string) *XML

func (*XML) String added in v0.5.1

func (x *XML) String(key, expect string) *XML

func (*XML) Time added in v1.0.0

func (x *XML) Time(key string, expect time.Time) *XML

func (*XML) True added in v1.0.0

func (x *XML) True(key string) *XML

func (*XML) Uint added in v1.0.0

func (x *XML) Uint(key string, expect uint64) *XML

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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