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 ¶
- func AssertNoSample(t testing.TB, sub dds.Subscriber, timeout time.Duration)
- func AssertSample(t testing.TB, sub dds.Subscriber, want []byte, timeout time.Duration)
- func BurstPublish(pub dds.Publisher, n int, payload []byte) error
- func NewParticipant(t testing.TB, domain dds.Domain) dds.Participant
- func PeriodicPublish(pub dds.Publisher, payload []byte, interval time.Duration, ...) error
- type TopicRecorder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertNoSample ¶
AssertNoSample asserts that no sample arrives on sub within timeout.
func AssertSample ¶
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 ¶
BurstPublish writes n copies of payload to pub. It returns the first error encountered, or nil if all writes succeed.
func NewParticipant ¶
NewParticipant creates a mock DDS participant on domain and registers t.Cleanup to close it when the test ends.
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.