servicetest

package
v0.0.0-...-e643149 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Code = packet.Code(123)

Variables

View Source
var MaxSendSize int

MaxSendSize overrides the maximum size of packets sent by service. Normally it is randomized and logged when creating an instance tester (but remember that Go caches test results). This variable can be set when debugging a test failure which might be caused by a particular value.

Don't override this permanently; all service implementations must work with arbitrarily large MaxSendSize setting.

Functions

func FactoryTest

func FactoryTest(ctx Context, t *testing.T, factory service.Factory, spec FactorySpec)

Types

type FactorySpec

type FactorySpec struct {
	NoStreams          bool
	AlwaysDiscoverable bool
}

type InstanceSpec

type InstanceSpec struct {
	Snapshot []byte
}

type InstanceTester

type InstanceTester struct {
	Instance service.Instance
	Sent     chan packet.Thunk // From service to program.
	// contains filtered or unexported fields
}

func NewInstanceTester

func NewInstanceTester(ctx Context, t *testing.T, factory service.Factory, spec InstanceSpec) *InstanceTester

func (*InstanceTester) Handle

func (inst *InstanceTester) Handle(ctx Context, t *testing.T, p packet.Buf) packet.Buf

func (*InstanceTester) Receive

func (inst *InstanceTester) Receive(ctx Context, t *testing.T) packet.Buf

Receive an item from the Sent channel.

func (*InstanceTester) Shutdown

func (inst *InstanceTester) Shutdown(ctx Context, t *testing.T)

Shutdown without suspension.

func (*InstanceTester) Suspend

func (inst *InstanceTester) Suspend(ctx Context, t *testing.T) []byte

Suspend calls Shutdown, expecting a snapshot.

func (*InstanceTester) ValidateSentPacket

func (inst *InstanceTester) ValidateSentPacket(t *testing.T, thunk packet.Thunk) packet.Buf

ValidateSentPacket thunk that was received from the Sent channel.

Jump to

Keyboard shortcuts

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