scenario

package
v0.45.0 Latest Latest
Warning

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

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

Documentation

Overview

Package scenario provides a declarative scenario DSL for DDS integration tests. A scenario is a sequence of Steps executed against a Participant. Steps include publishing samples, expecting samples, waiting for quiet periods, and running custom assertions.

Example:

err := scenario.Run(ctx, p,
    scenario.Publish("sensor/temp", []byte("42"), dds.DefaultQoS),
    scenario.Expect("sensor/temp", dds.DefaultQoS, 100*time.Millisecond, nil),
)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, p dds.Participant, steps ...Step) error

Run executes steps in order against p. Returns the first error encountered. Each step's context carries the outer ctx so cancellation propagates.

Types

type Step

type Step interface {
	// contains filtered or unexported methods
}

Step is a single action in a scenario.

func Assert

func Assert(desc string, fn func(ctx context.Context, p dds.Participant) error) Step

Assert returns a Step that calls fn. desc is used in error messages.

func Expect

func Expect(topic string, qos dds.QoS, timeout time.Duration, match func(dds.Sample) bool) Step

Expect returns a Step that subscribes to topic and waits up to timeout for a sample. If match is non-nil, the step fails if the received sample does not satisfy the predicate.

func ExpectNone

func ExpectNone(topic string, qos dds.QoS, timeout time.Duration) Step

ExpectNone returns a Step that fails if any sample arrives on topic within timeout.

func Publish

func Publish(topic string, payload []byte, qos dds.QoS) Step

Publish returns a Step that creates a publisher, writes payload, and closes it.

func Wait

func Wait(d time.Duration) Step

Wait returns a Step that sleeps for d, respecting context cancellation.

Jump to

Keyboard shortcuts

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