Documentation ¶
Overview ¶
Package testserver configures and creates a Fleetspeak server instance suitable for unit tests. It also provides utility methods for directly adjusting the server state in tests.
Index ¶
- type FakeCommunicator
- type Server
- func (s Server) AddClient() (crypto.PublicKey, error)
- func (s Server) GetMessage(ctx context.Context, id common.MessageID) *fspb.Message
- func (s Server) ProcessMessageFromClient(k crypto.PublicKey, msg *fspb.Message) error
- func (s Server) SimulateContactFromClient(ctx context.Context, key crypto.PublicKey, msgs []*fspb.Message) ([]*fspb.Message, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeCommunicator ¶
type FakeCommunicator struct {
Dest *Server
}
FakeCommunicator implements comms.Communicator to do nothing by save the comms.Context to a Server. Most users should simply call Make, but this is exposed in order to support more flexible setup of test servers.
func (FakeCommunicator) Start ¶
func (c FakeCommunicator) Start() error
func (FakeCommunicator) Stop ¶
func (c FakeCommunicator) Stop()
type Server ¶
Server is a test server, with related structures and interfaces to allow tests to manipulate it.
func Make ¶
Make creates a server.Server using the provided communicators. It creates and attaches it to an sqlite datastore based on the test and test case names.
func MakeWithService ¶
func MakeWithService(t *testing.T, testName, caseName string, serviceInstance service.Service) Server
MakeWithService creates a server.Server using the provided service. Like in Make(), a sqlite datastore is created for the provided test-case.
func (Server) GetMessage ¶
GetMessage retrieves a single message from the datastore, or dies trying.
func (Server) ProcessMessageFromClient ¶
ProcessMessageFromClient delivers a message to a server, simulating that it was provided by a client. It then waits up to 30 seconds for it to be processed.
func (Server) SimulateContactFromClient ¶
func (s Server) SimulateContactFromClient(ctx context.Context, key crypto.PublicKey, msgs []*fspb.Message) ([]*fspb.Message, error)
SimulateContactFromClient accepts zero or more messages as if they came from a client, and returns any messages pending for delivery to the client.