httptest

package
v0.0.0-...-58692e4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpErrorUri   = "proxy://www.httperror.com"
	BodyIOErrorUri = "proxy://www.bodyioerror.com"
)

Variables

This section is empty.

Functions

func BodyIOErrorProxy

func BodyIOErrorProxy(req *http.Request) (*http.Response, error)

BodyIOErrorProxy - reusable body I/O error proxy

func ErrorProxy

func ErrorProxy(req *http.Request) (*http.Response, error)

ErrorProxy - test proxy for http and body I/O errors

func HttpErrorProxy

func HttpErrorProxy(req *http.Request) (*http.Response, error)

HttpErrorProxy - reusable http error proxy

func NewIOErrorResponse

func NewIOErrorResponse() *http.Response

NewIOErrorResponse - create a respons that contains a body that will generate an I/O error when read

func NewResponse

func NewResponse(httpStatus int, content []byte, kv ...string) *http.Response

NewResponse - create a new response from the provided parameters

func Pattern

func Pattern(req *http.Request) string

func ReadResponse

func ReadResponse(f fs.FS, name string) (*http.Response, error)

ReadResponse - create a response by reading the content from ad embedded file system

func ReadResponseTest

func ReadResponseTest(name string) (*http.Response, error)

ReadResponseTest - only used for calls scoped to the enclosing http package, specifically from do_test.go.

Types

type ReaderCloser

type ReaderCloser struct {
	Reader io.Reader
	Err    error
}

ReaderCloser - test type for a body.ReadCloser interface

func NewReaderCloser

func NewReaderCloser(reader io.Reader, err error) *ReaderCloser

func (*ReaderCloser) Close

func (r *ReaderCloser) Close() error

func (*ReaderCloser) Read

func (r *ReaderCloser) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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