Help us shape the future of Go! Take the 2026 Go Developer Survey

notifications

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 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 marks the calling function as a test helper.
	Helper()
	// Errorf reports a formatted test failure.
	Errorf(string, ...any)
}

TestingT is the test reporting contract used by notification assertions.

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)

Deliver returns the configured outcome, recording accepted or unknown deliveries while capacity remains. Cancellation or full capacity requests retry.

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