streamtest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package streamtest contains a common test suite for eventstream.Stream implementations.

Index

Constants

View Source
const (
	// DefaultTestTimeout is the default test timeout.
	DefaultTestTimeout = 3 * time.Second

	// DefaultAssumeBlockingDuration is the default "assumed blocking duration".
	DefaultAssumeBlockingDuration = 10 * time.Millisecond
)

Variables

This section is empty.

Functions

func Declare

func Declare(
	before func(context.Context, In) Out,
	after func(),
)

Declare declares generic behavioral tests for a specific stream implementation.

Types

type In

type In struct {
	// Application is a test application that is configured to record the events
	// used within the test suite.
	Application configkit.RichApplication

	// EventTypes is the set of event types that the test application produces.
	EventTypes message.TypeCollection

	// Marshaler marshals and unmarshals the test message types.
	Marshaler marshalkit.Marshaler
}

In is a container for values that are provided to the stream-specific "before" function.

type Out

type Out struct {
	// Stream is the stream under test.
	Stream eventstream.Stream

	// TestTimeout is the maximum duration allowed for each test.
	TestTimeout time.Duration

	// AssumeBlockingDuration specifies how long the tests should wait before
	// assuming a call to Cursor.Next() is successfully blocking, waiting for a
	// new message, as opposed to in the process of "checking" if any messages
	// are already available.
	AssumeBlockingDuration time.Duration

	// Append is a function that appends messages to the stream.
	Append func(context.Context, ...parcel.Parcel)
}

Out is a container for values that are provided by the stream-specific "before" function.

Jump to

Keyboard shortcuts

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