mock

package
v0.0.0-...-1553c39 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientPatcher

type ClientPatcher struct {
	OriginalTransport http.RoundTripper
	MockTransport     http.RoundTripper
	// contains filtered or unexported fields
}

ClientPatcher is a helper structure which will contains the client will be patched, the original transport and mock transport.

func PatchClient

func PatchClient(httpClient *http.Client, targetServers ...*TargetServer) *ClientPatcher

PatchClient will replace the original transport with mock transport. It will return ClientPatcher for remove the mock transport after using it.

func (*ClientPatcher) RemovePatch

func (httpReq *ClientPatcher) RemovePatch()

RemovePatch will replace the mock transport with original.

type ResponseHandler

type ResponseHandler struct {
	WriteToBody func() []byte
	StatusCode  int
	Path        string
	Method      string
}

ResponseHandler contains a mock response and a request should be handled.

type TargetServer

type TargetServer struct {
	Host             string
	ResponseHandlers []*ResponseHandler
}

func NewTargetServer

func NewTargetServer(host string) *TargetServer

NetTargetServer will returns TargetServer with the host.

func (*TargetServer) AddResponseHandler

func (s *TargetServer) AddResponseHandler(r *ResponseHandler) *TargetServer

AddResponseHandler will add ResponseHandler to the TargetServer.

Jump to

Keyboard shortcuts

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