mocks

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

README

Mocks

Several mocks for testing. Code taken from ooni/probe-cli/internal/model/mocks

(c) Simone Basso, 2021.
License: GPL-3.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	MockString  func() string
	MockNetwork func() string
}

Addr allows mocking net.Addr.

func (*Addr) Network

func (a *Addr) Network() string

Network calls MockNetwork.

func (*Addr) String

func (a *Addr) String() string

String calls MockString.

type Conn

type Conn struct {
	Count                int
	MockRead             func(b []byte) (int, error)
	MockWrite            func(b []byte) (int, error)
	MockClose            func() error
	MockLocalAddr        func() net.Addr
	MockRemoteAddr       func() net.Addr
	MockSetDeadline      func(t time.Time) error
	MockSetReadDeadline  func(t time.Time) error
	MockSetWriteDeadline func(t time.Time) error
}

Conn is a mockable net.Conn.

func (*Conn) Close

func (c *Conn) Close() error

Close calls MockClose.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr calls MockLocalAddr.

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

Read calls MockRead.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr calls MockRemoteAddr.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline calls MockSetDeadline.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline calls MockSetReadDeadline.

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline calls MockSetWriteDeadline.

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

Write calls MockWrite.

type Dialer

type Dialer struct {
	MockDialContext          func(ctx context.Context, network, address string) (net.Conn, error)
	MockCloseIdleConnections func()
}

Dialer is a mockable Dialer.

func (*Dialer) CloseIdleConnections

func (d *Dialer) CloseIdleConnections()

CloseIdleConnections calls MockCloseIdleConnections.

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext calls MockDialContext.

Jump to

Keyboard shortcuts

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