test

package
v2.15.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package test provides Client test helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockReceiverClient

func NewMockReceiverClient(t *testing.T, chanSize int, opts ...client.Option) (client.Client, chan<- event.Event)

NewMockReceiverClient returns a client that can Receive events, without replying. The returned channel is the channel for sending messages to the client

func NewMockRequesterClient

func NewMockRequesterClient(t *testing.T, chanSize int, replierFn func(inMessage event.Event) (*event.Event, protocol.Result), opts ...client.Option) (client.Client, <-chan event.Event)

NewMockRequesterClient returns a client that can perform Send() event and Request() event. All sent messages are delivered to the returned channel.

func NewMockResponderClient

func NewMockResponderClient(t *testing.T, chanSize int, opts ...client.Option) (client.Client, chan<- event.Event, <-chan ClientMockResponse)

NewMockResponderClient returns a client that can Receive events and reply. The first returned channel is the channel for sending messages to the client, while the second one contains the eventual responses.

func NewMockSenderClient

func NewMockSenderClient(t *testing.T, chanSize int, opts ...client.Option) (client.Client, <-chan event.Event)

NewMockSenderClient returns a client that can Send() event. All sent messages are delivered to the returned channel.

func SendReceive

func SendReceive(t *testing.T, protocolFactory func() interface{}, in event.Event, outAssert func(e event.Event), opts ...client.Option)

SendReceive does client.Send(in), then it receives the message using client.StartReceiver() and executes outAssert Halt test on error.

Types

type ClientMockResponse

type ClientMockResponse struct {
	Event  event.Event
	Result protocol.Result
}

Jump to

Keyboard shortcuts

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