scenario

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMsgSkip is an error returned when checking a received msg when a msg
	// is not to be checked.
	ErrScenarioMsgSkip = errors.New("msg skipped")
)

Functions

This section is empty.

Types

type Scenario

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

Scenario represents a series of steps where messages can be sent, received, and checked.

func NewScenario

func NewScenario(ws *websocket.Conn) *Scenario

NewScenario creates a scenario.

func (*Scenario) Receive

func (s *Scenario) Receive(checks ...ScenarioCheck) *Scenario

Receive creates a step where a message is received and then checked with the given checks.

func (*Scenario) Run

func (s *Scenario) Run(ctx context.Context) error

Run launches the scenario.

func (*Scenario) Send

func (s *Scenario) Send(newMsg func() hwebsocket.ProtoMsg) *Scenario

Send creates a step where the given message is sent.

type ScenarioCheck

type ScenarioCheck func(msg hwebsocket.Msg) error

ScenarioCheck represents a function that is used to check a received message within a scenario.

Returning ErrScenarioMsgSkip skips the current message and the check will be reused on the next received message.

Any other returned error stops the scenario.

func FilterByRequestID

func FilterByRequestID(v uint32) ScenarioCheck

FilterByRequestID is a check that skips every received message that does not have the given request id.

func FilterByType

func FilterByType(types ...protoreflect.Enum) ScenarioCheck

FilterByType is a check that skips every received message that does not have one of the given types.

Jump to

Keyboard shortcuts

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