testutils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Error is a trigger to fail with http.Error
	Error bool
	// ErrorText is an argument for http.Error in the case of Error == true
	ErrorText string
	// Code is a status code returned in response
	Code int
	// Delay represents the amount of time that handler will wait before response
	Delay time.Duration
	// FailEachNthRequest defines the period of requests failure
	FailEachNthRequest int
	// FailEachNthCode defines the status code to be returned during periodical requests failure
	FailEachNthCode int
	// FailThreshold defines the threshold of successfully processed requests, after which mocked responses will be returned
	FailThreshold int
	// FailThresholdCode defines the status code to be returned after threshold overcome
	FailThresholdCode int
	// pemPath and keyPath are paths to certs that required by https server
	PemPath string
	KeyPath string
}

Options represents the amount of options for mock ups

type Proxy

type Proxy struct {

	// FailEachNthRequestCounter is a counter required for failing condition on each nth request
	FailEachNthRequestCounter int
	// FailThresholdCounter is a counter required for failing condition after threshold has been reached
	FailThresholdCounter int
	// contains filtered or unexported fields
}

Proxy is a struct of proxy wrapper

func NewProxy

func NewProxy(transport http.RoundTripper, options *Options) (*Proxy, error)

NewProxy is a proxy constructor

func (*Proxy) SetTransportProxy added in v0.1.0

func (p *Proxy) SetTransportProxy() error

SetTransportProxy changes http.DefaultTransport to the one that uses current server as a proxy

func (*Proxy) Start

func (p *Proxy) Start() error

Start starts proxy server

func (*Proxy) Stop

func (p *Proxy) Stop()

Stop stops proxy server

Jump to

Keyboard shortcuts

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