streamtest

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package streamtest provides a reusable behavioral suite for contract stream adapters. It is intended for adapter tests, not production call paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Verify

func Verify[Send, Receive any](
	t *testing.T,
	open OpenFunc[Send, Receive],
	config contract.StreamConfig,
	inputs []Send,
	echo func(Send) Receive,
)

Verify runs the transport-neutral lifecycle, ordering, cancellation, slow-consumer delivery, transaction, context-firewall, terminal-error, root-cancellation, max-duration, and idle checks against a bidi adapter. It requires at least one input value and a deterministic echo mapper. The adapter is responsible for mapping the supplied handler to its test server. Exact queue blocking, process-local error causes, and remote-handler close budgets are transport-specific and should be asserted by the adapter's own tests.

func VerifyServer added in v0.10.0

func VerifyServer[T any](t *testing.T, open ServerOpenFunc[T], config contract.StreamConfig, values []T)

VerifyServer checks the common receive-only capabilities of Local, SSE and WebSocket adapters. Verify separately covers bidirectional capabilities; this suite does not imply SSE supports Send or CloseSend. Protocol parsing, credential expiry and per-frame limits remain adapter-specific tests.

Types

type OpenFunc

type OpenFunc[Send, Receive any] func(
	context.Context,
	contract.StreamConfig,
	contract.StreamHandler[Send, Receive],
) (contract.ClientStream[Send, Receive], error)

OpenFunc adapts a transport's stream opener to the conformance suite. An implementation may start a local server or test fixture before returning its ClientStream; the supplied handler defines that fixture's server behavior.

type ServerOpenFunc added in v0.10.0

type ServerOpenFunc[T any] func(context.Context, contract.StreamConfig,
	func(context.Context, func(context.Context, T) error) error) (contract.ServerStream[T], error)

ServerOpenFunc adapts a receive-only stream to the shared lifecycle suite. produce represents the remote producer, and send emits one response. Fixtures must establish the response independently from the first application event (for example, SSE can flush a comment). No client Send capability is assumed.

Jump to

Keyboard shortcuts

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