httpmock

package
Version: v0.3.431 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 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 RepoNetworkStubResponse

func RepoNetworkStubResponse(owner, repo, defaultBranch, permission string) string

func ScopesResponder

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

Types

type Matcher

type Matcher func(req *http.Request) bool

func GraphQL

func GraphQL(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 (*Registry) Register

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

func (*Registry) RoundTrip

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

RoundTrip satisfies http.RoundTripper

func (*Registry) StubRepoInfoResponse

func (r *Registry) StubRepoInfoResponse(owner, repo, branch string)

func (*Registry) StubRepoResponse

func (r *Registry) StubRepoResponse(owner, repo string)

func (*Registry) StubRepoResponseWithPermission

func (r *Registry) StubRepoResponseWithPermission(owner, repo, permission string)

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 GraphQLMutation

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

func GraphQLQuery

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

func JSONResponse

func JSONResponse(body 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
t or T : Toggle theme light dark auto
y or Y : Canonical URL