jsonwstesting

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2017 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package jsonwstesting defines helpers to test web sockets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockClose

type MockClose struct {
	// The number of times the function was called.
	CalledCount int

	// An optional implementation of the function.
	Fn func() error
}

MockClose mocks the Close function.

type MockConn

type MockConn struct {
	// The mock for the Close function.
	MockClose MockClose

	// The mock for the WriteJSON function.
	MockWriteJSON MockWriteJSON

	// The mock for the ReadJSON function.
	MockReadJSON MockReadJSON

	// The mock for the SetReadLimit function.
	MockSetReadLimit MockSetReadLimit

	// The mock for the SetReadDeadline function.
	MockSetReadDeadline MockSetReadDeadline

	// The mock for the SetWriteDeadline function.
	MockSetWriteDeadline MockSetWriteDeadline

	// The mock for the SetPongHandler function.
	MockSetPongHandler MockSetPongHandler

	// The mock for the Ping function.
	MockPing MockPing
}

MockConn is used to mock a connection.

It implements github.com/stratumn/sdk/jsonws.Conn and github.com/stratumn/sdk/jsonws.PingableConn.

func (*MockConn) Close

func (a *MockConn) Close() error

Close implements github.com/stratumn/sdk/jsonws.Conn.Close.

func (*MockConn) Ping

func (a *MockConn) Ping() error

Ping implements github.com/stratumn/sdk/jsonws.PingableConn.Ping.

func (*MockConn) ReadJSON

func (a *MockConn) ReadJSON(msg interface{}) error

ReadJSON implements github.com/stratumn/sdk/jsonws.Conn.ReadJSON.

func (*MockConn) SetPongHandler

func (a *MockConn) SetPongHandler(h func(string) error)

SetPongHandler implements github.com/stratumn/sdk/jsonws.Conn.SetPongHandler.

func (*MockConn) SetReadDeadline

func (a *MockConn) SetReadDeadline(t time.Time) error

SetReadDeadline implements github.com/stratumn/sdk/jsonws.Conn.SetReadDeadline.

func (*MockConn) SetReadLimit

func (a *MockConn) SetReadLimit(limit int64)

SetReadLimit implements github.com/stratumn/sdk/jsonws.Conn.SetReadLimit.

func (*MockConn) SetWriteDeadline

func (a *MockConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements github.com/stratumn/sdk/jsonws.Conn.SetWriteDeadline.

func (*MockConn) WriteJSON

func (a *MockConn) WriteJSON(msg interface{}) error

WriteJSON implements github.com/stratumn/sdk/jsonws.Conn.WriteJSON.

type MockPing

type MockPing struct {
	// The number of times the function was called.
	CalledCount int

	// An optional implementation of the function.
	Fn func() error
}

MockPing mocks the SetPing function.

type MockReadJSON

type MockReadJSON struct {
	// The number of times the function was called.
	CalledCount int

	// The channel that was passed to each call.
	CalledWith []interface{}

	// The last channel that was passed.
	LastCalledWith interface{}

	// An optional implementation of the function.
	Fn func(interface{}) error
}

MockReadJSON mocks the ReadJSON function.

type MockSetPongHandler

type MockSetPongHandler struct {
	// The number of times the function was called.
	CalledCount int

	// The channel that was passed to each call.
	CalledWith []func(string) error

	// The last channel that was passed.
	LastCalledWith func(string) error

	// An optional implementation of the function.
	Fn func(func(string) error)
}

MockSetPongHandler mocks the SetPongHandler function.

type MockSetReadDeadline

type MockSetReadDeadline struct {
	// The number of times the function was called.
	CalledCount int

	// The channel that was passed to each call.
	CalledWith []time.Time

	// The last channel that was passed.
	LastCalledWith time.Time

	// An optional implementation of the function.
	Fn func(time.Time) error
}

MockSetReadDeadline mocks the SetReadDeadline function.

type MockSetReadLimit

type MockSetReadLimit struct {
	// The number of times the function was called.
	CalledCount int

	// The channel that was passed to each call.
	CalledWith []int64

	// The last channel that was passed.
	LastCalledWith int64

	// An optional implementation of the function.
	Fn func(int64)
}

MockSetReadLimit mocks the SetReadLimit function.

type MockSetWriteDeadline

type MockSetWriteDeadline struct {
	// The number of times the function was called.
	CalledCount int

	// The channel that was passed to each call.
	CalledWith []time.Time

	// The last channel that was passed.
	LastCalledWith time.Time

	// An optional implementation of the function.
	Fn func(time.Time) error
}

MockSetWriteDeadline mocks the SetWriteDeadline function.

type MockWriteJSON

type MockWriteJSON struct {
	// The number of times the function was called.
	CalledCount int

	// The channel that was passed to each call.
	CalledWith []interface{}

	// The last channel that was passed.
	LastCalledWith interface{}

	// An optional implementation of the function.
	Fn func(interface{}) error
}

MockWriteJSON mocks the WriteJSON function.

Jump to

Keyboard shortcuts

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