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.