testutil

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBoard

func BuildBoard(p1, p2 []Move) (board common.Board)

func DumpTableOnFailure

func DumpTableOnFailure()

DumpTableOnFailure can be passed to ginkgo.JustAfterEach to dump the DB table to log output if an assertion failed.

func ExpectNewGameBoard

func ExpectNewGameBoard(client **Client) func()

func ExpectNoOpenGames

func ExpectNoOpenGames(client **Client) func()

func ExpectOpenGames

func ExpectOpenGames(client **Client, hosts ...string) func()

func ExpectPlayerLeft

func ExpectPlayerLeft(client **Client, player string) func()

func ExpectTurn

func ExpectTurn(client **Client, player common.Disk) func()

func HaveReceived

func HaveReceived(messageRef interface{}) types.GomegaMatcher

HaveReceived returns a custom matcher that checks that the client has received at least one message of a given type.

messageRef is a pointer to a message struct of the expected type. The matcher will set the value of the pointer to most recently received message of the type.

func Send

func Send(client **Client, messageToSend interface{}) func()

Send is a convenience wrapper around Client.Send which can be used directly as an argument to ginkgo.BeforeEach.

Types

type Client

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

func (*Client) Connect

func (c *Client) Connect()

Connect sends a CONNECT message to server.Handle and waits for server.Handle to return.

func (*Client) Disconnect

func (c *Client) Disconnect()

Connect sends a DISCONNECT message to server.Handle and waits for server.Handle to return.

func (*Client) Send

func (c *Client) Send(message interface{})

Send marshals and then sends the specified message to server.Handle and waits for server.Handle to return. Any outbound messages from the server are sent to and received by all other registered test clients before this method returns.

type Move

type Move [2]int

type Tester

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

func Init

func Init() *Tester

Init returns a new Tester that has the ability to test the server.Handle function. It should typically be called during setup for a BDD test.

func (*Tester) NewClient

func (h *Tester) NewClient() *Client

NewClient registers and returns a new Client, which has methods for sending messages to the server.Handle function.

Jump to

Keyboard shortcuts

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