mock

package
v2.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Send(pkt interface{}) error
	Receive() (interface{}, error)
	Close() error
}

A Conn defines an abstract interface for connections used with a Flow.

type Flow

type Flow struct {
	// contains filtered or unexported fields
}

A Flow is a sequence of actions that can be tested against a connection.

func NewFlow

func NewFlow() *Flow

NewFlow returns a new flow.

func (*Flow) Close

func (f *Flow) Close() *Flow

Close will immediately close the connection.

func (*Flow) Debug

func (f *Flow) Debug() *Flow

Debug will activate the debug mode.

func (*Flow) End

func (f *Flow) End() *Flow

End will match proper connection close.

func (*Flow) Receive

func (f *Flow) Receive(pkts ...interface{}) *Flow

Receive will receive and match the specified packets out of order.

func (*Flow) Run

func (f *Flow) Run(fn func()) *Flow

Run will call the supplied function and wait until it returns.

func (*Flow) Send

func (f *Flow) Send(pkts ...interface{}) *Flow

Send will send the specified packets.

func (*Flow) Skip

func (f *Flow) Skip(pkts ...interface{}) *Flow

Skip will receive the specified packets without matching out of order.

func (*Flow) Test

func (f *Flow) Test(conn Conn) error

Test starts the flow on the given Conn and reports to the specified test.

func (*Flow) TestAsync

func (f *Flow) TestAsync(conn Conn, timeout time.Duration) <-chan error

TestAsync starts the flow on the given Conn and reports to the specified test asynchronously.

type Pipe

type Pipe struct {
	// contains filtered or unexported fields
}

The Pipe pipes packets from Send to Receive.

func NewPipe

func NewPipe() *Pipe

NewPipe returns a new Pipe.

func (*Pipe) Close

func (conn *Pipe) Close() error

Close will close the conn and let Send and Receive return errors.

func (*Pipe) Receive

func (conn *Pipe) Receive() (interface{}, error)

Receive returns the packet being sent with Send.

func (*Pipe) Send

func (conn *Pipe) Send(pkt interface{}) error

Send returns packet on next Receive call.

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response the mocked http repsonse

func NewResponse

func NewResponse(status int, body []byte) *Response

NewResponse create a new repsonse

type Server

type Server struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Server the mocked http server

func NewServer

func NewServer(tlsConfig *tls.Config, responses ...*Response) *Server

NewServer create a new mocked server

Jump to

Keyboard shortcuts

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