testutil

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package testutil provides test-harness helpers for DDS participants. It is intended for use in _test.go files only; production code must not import this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNoSample

func AssertNoSample(t testing.TB, sub dds.Subscriber, timeout time.Duration)

AssertNoSample asserts that no sample arrives on sub within timeout.

func AssertSample

func AssertSample(t testing.TB, sub dds.Subscriber, want []byte, timeout time.Duration)

AssertSample blocks until a sample arrives on sub and asserts that its payload equals want. The test is fatal if no sample arrives within timeout or if the payload does not match.

func BurstPublish

func BurstPublish(pub dds.Publisher, n int, payload []byte) error

BurstPublish writes n copies of payload to pub. It returns the first error encountered, or nil if all writes succeed.

func NewParticipant

func NewParticipant(t testing.TB, domain dds.Domain) dds.Participant

NewParticipant creates a mock DDS participant on domain and registers t.Cleanup to close it when the test ends.

func PeriodicPublish

func PeriodicPublish(pub dds.Publisher, payload []byte, interval time.Duration, stop <-chan struct{}) error

PeriodicPublish publishes payload at the given interval until stop is closed. It returns the first write error, or nil.

Types

type TopicRecorder

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

TopicRecorder records every sample delivered to a subscriber. Call Start to begin, Stop to end, and Samples to retrieve what was captured.

func NewTopicRecorder

func NewTopicRecorder(sub dds.Subscriber) *TopicRecorder

NewTopicRecorder creates a recorder bound to sub. Call Start to begin.

func (*TopicRecorder) Count

func (r *TopicRecorder) Count() int

Count returns the number of samples recorded so far.

func (*TopicRecorder) DrainSamples

func (r *TopicRecorder) DrainSamples() []dds.Sample

DrainSamples returns and clears all samples recorded so far.

func (*TopicRecorder) Samples

func (r *TopicRecorder) Samples() []dds.Sample

Samples returns a copy of all samples recorded so far.

func (*TopicRecorder) Start

func (r *TopicRecorder) Start() *TopicRecorder

Start launches the background recording goroutine. Returns r for chaining.

func (*TopicRecorder) Stop

func (r *TopicRecorder) Stop()

Stop ends recording. Safe to call multiple times.

func (*TopicRecorder) WaitFor

func (r *TopicRecorder) WaitFor(n int, timeout time.Duration) bool

WaitFor blocks until at least n samples have been recorded or timeout elapses. Returns true if the target count was reached.

Directories

Path Synopsis
Package scenario provides a declarative scenario DSL for DDS integration tests.
Package scenario provides a declarative scenario DSL for DDS integration tests.

Jump to

Keyboard shortcuts

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