httptest

package
v0.0.0-...-db335bc Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMockFn = func(req *http.Request) (*http.Response, error) {
	res := &http.Response{}
	res.Body = StubbedBody()
	return res, nil
}
View Source
var HandlerStubFn = func(in string, handler func(w http.ResponseWriter, r *http.Request)) {}
View Source
var ListenAndServeStubFn = func(addr string, handler http.Handler) error { return nil }
View Source
var MockFn = DefaultMockFn
View Source
var NewRequestStubFn = func(method, url string, body io.Reader) (*http.Request, error) {
	return http.NewRequest(method, url, body)
}

Functions

func StubbedBody

func StubbedBody() io.ReadCloser

func StubbedResponseWriter

func StubbedResponseWriter() http.ResponseWriter

Types

type BodyMock

type BodyMock struct{}

type ClientMock

type ClientMock struct{}

func (*ClientMock) Do

func (c *ClientMock) Do(req *http.Request) (*http.Response, error)

func (*ClientMock) HandleFunc

func (c *ClientMock) HandleFunc(path string, handler func(http.ResponseWriter, *http.Request))

func (*ClientMock) ListenAndServe

func (c *ClientMock) ListenAndServe(addr string, handler http.Handler) error

func (*ClientMock) NewRequest

func (c *ClientMock) NewRequest(method, url string, body io.Reader) (*http.Request, error)

Jump to

Keyboard shortcuts

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