httptest

package
v2.11.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JsonContentType   = "application/json"
	FormEncodedType   = "application/x-www-form-urlencoded"
	ContentTypeHeader = "Content-Type"
)

Variables

This section is empty.

Functions

func GetBody

func GetBody(body io.ReadCloser) []byte

Types

type RequestTester

type RequestTester struct {
	Delay         string `json:"delay"`
	DelayDuration time.Duration
	DelayOnCall   int `json:"delay_on_call"`
}

type Responder

type Responder struct {
	Body      string              `json:"body"`
	CallCount int                 `json:"call_count"`
	Method    string              `json:"method"`
	Error     string              `json:"error"`
	Headers   map[string][]string `json:"headers"`
	Path      string              `json:"path"`
}

type TestServer

type TestServer struct {
	Server    *httptest.Server
	URL       string
	CallCount int
	Mutex     sync.Mutex
}

func NewTestServer

func NewTestServer(statusCode int) *TestServer

func (*TestServer) Close

func (ts *TestServer) Close()

func (*TestServer) GetCalls

func (ts *TestServer) GetCalls(delta int) int

Jump to

Keyboard shortcuts

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