httpmock

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchAny

func MatchAny(*http.Request) bool

func ScopesResponder

func ScopesResponder(scopes string) func(*http.Request) (*http.Response, error)

Types

type Matcher

type Matcher func(req *http.Request) bool

func GQL

func GQL(q string) Matcher

func REST

func REST(method, p string) Matcher

type Registry

type Registry struct {
	Requests []*http.Request
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(t *testing.T) *Registry

func (*Registry) Register

func (r *Registry) Register(m Matcher, resp Responder)

func (*Registry) RoundTrip

func (r *Registry) RoundTrip(req *http.Request) (*http.Response, error)

Registry satisfies http.RoundTripper interface.

func (*Registry) Verify

func (r *Registry) Verify(t Testing)

type Responder

type Responder func(req *http.Request) (*http.Response, error)

func FileResponse

func FileResponse(filename string) Responder

func GQLMutation

func GQLMutation(body string, cb func(map[string]interface{})) Responder

func GQLQuery

func GQLQuery(body string, cb func(string, map[string]interface{})) Responder

func JSONResponse

func JSONResponse(body interface{}) Responder

func RESTPayload

func RESTPayload(responseStatus int, responseBody string, cb func(payload map[string]interface{})) Responder

func StatusStringResponse

func StatusStringResponse(status int, body string) Responder

func StringResponse

func StringResponse(body string) Responder

type Stub

type Stub struct {
	Matcher   Matcher
	Responder Responder
	// contains filtered or unexported fields
}

type Testing

type Testing interface {
	Errorf(string, ...interface{})
	Helper()
}

Jump to

Keyboard shortcuts

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