harness

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DDPFirstRandomID = "vQrh9EH6JAa437k35"

DDPFirstRandomID is the first ID the server will pick, given DDPRandomSeed

View Source
const DDPRandomSeed = "someseed"

DDPRandomSeed is the seed we send to Meteor with method calls

Variables

This section is empty.

Functions

func Start

func Start() (*DDPConn, *DDPConn)

Start connects to both Meteor servers and returns (server 1 conn, server 2 conn)

func StartWithFixtures

func StartWithFixtures(fixtures helpers.DBData) (*DDPConn, *DDPConn)

StartWithFixtures is like Start, but seeds the Mongo DB with a given set of records

func Stop

func Stop()

Stop disconnects from both meteor servers

Types

type DDPConn

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

DDPConn represents a connection to a Meteor server. It allows you to send messages, and make assertions about the messages that are sent back

func (*DDPConn) ClearReceiveBuffer

func (conn *DDPConn) ClearReceiveBuffer()

ClearReceiveBuffer clears the buffer of messages that will be compared on the next call to VerifyReceive. It doesn't return until no message have been received for 3 seconds.

func (*DDPConn) Close

func (conn *DDPConn) Close()

Close closes a websocket

func (*DDPConn) Send

func (conn *DDPConn) Send(msg *DDPMsg) error

Send a message to the server

func (*DDPConn) VerifyReceive

func (conn *DDPConn) VerifyReceive(t *testing.T, expectedMessageGroups ...DDPMsgGroup)

VerifyReceive reads messages from the Meteor server until no messages have been received for 3 seconds, and then checks that the received messages match the expected messages.

VerifyReceive takes an arbitrary number of "message groups". When checking against the received messages, messages within a single group can be in any order.

For example, if we specify our expected groups as [(a b), (c d), (e)], then (b a d c e) would be OK, but (a c b d e), (a b c d), and (a b c d e f) would not be OK.

type DDPData

type DDPData map[string]interface{}

DDPData is a simple alias for EJSON data

type DDPMsg

type DDPMsg struct {
	DDPType string
	Data    DDPData
}

DDPMsg represents a single message sent to or received from a Meteor server

func DDPAdded

func DDPAdded(collection, id string, fields DDPData) *DDPMsg

DDPAdded constructs a DDP added message

func DDPChanged

func DDPChanged(collection, id string, fields DDPData, cleared []string) *DDPMsg

DDPChanged constructs a DDP changed message

func DDPMethod

func DDPMethod(id, method string, params ...interface{}) *DDPMsg

DDPMethod constructs a DDP method message

func DDPReady

func DDPReady(id string) *DDPMsg

DDPReady constructs a DDP ready message

func DDPRemoved

func DDPRemoved(collection, id string) *DDPMsg

DDPRemoved constructs a DDP removed message

func DDPResult

func DDPResult(id string, result DDPData) *DDPMsg

DDPResult constructs a DDP result message

func DDPSub

func DDPSub(id, name string, params ...interface{}) *DDPMsg

DDPSub constructs a DDP sub message

func DDPUpdated

func DDPUpdated(methods []string) *DDPMsg

DDPUpdated constructs a DDP updated message

type DDPMsgGroup

type DDPMsgGroup []*DDPMsg

DDPMsgGroup is a slice of *DDPMsg

Jump to

Keyboard shortcuts

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