notifications

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package notifications supplies a recording custom-channel transport for tests. Bind it with notifications.Custom so tests exercise the production manager, storage and claim protocol; only the external send is replaced. Assertion failure text never includes rendered outputs or delivery IDs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDelivered

func AssertDelivered[D any](t TestingT, r *Transport[D], match func(D) bool)

AssertDelivered requires at least one recorded output satisfying match (nil matches any).

func AssertDeliveredCount

func AssertDeliveredCount[D any](t TestingT, r *Transport[D], match func(D) bool, want int)

AssertDeliveredCount requires exactly want recorded outputs satisfying match.

func AssertNotDelivered

func AssertNotDelivered[D any](t TestingT, r *Transport[D], match func(D) bool)

AssertNotDelivered requires that no recorded output satisfies match.

Types

type Delivery

type Delivery[D any] struct {
	ID   notifications.DeliveryID
	Data D
}

Delivery is one recorded send.

type TestingT

type TestingT interface {
	Helper()
	Errorf(string, ...any)
}

type Transport

type Transport[D any] struct {
	// contains filtered or unexported fields
}

Transport records delivered outputs in arrival order and answers with the configured outcome (Accepted by default). It is bounded by its capacity.

func New

func New[D any](t testing.TB, capacity int) *Transport[D]

New owns a recorder whose private outputs are cleared when the test ends.

func (*Transport[D]) Deliver

func (r *Transport[D]) Deliver(ctx context.Context, id notifications.DeliveryID, data D) (notifications.Outcome, error)

func (*Transport[D]) Deliveries

func (r *Transport[D]) Deliveries() []Delivery[D]

Deliveries returns a copy of the accepted (or unknown-outcome) sends.

func (*Transport[D]) Reset

func (r *Transport[D]) Reset()

Reset clears recorded outputs.

func (*Transport[D]) Respond

func (r *Transport[D]) Respond(outcome notifications.Outcome)

Respond selects the outcome for later deliveries, for example Retry to exercise a retry or Unknown to exercise an operator resolution.

Jump to

Keyboard shortcuts

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