mocks

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gorcure

type Gorcure struct {
	// Updates holds every update passed to Publish/PublishUpdate, in order.
	Updates []contracts.Update
	// ID is the fake event id returned by every call.
	ID string
	// Err, when set, is returned by every call without recording the update.
	Err error
}

Gorcure is a test double recording every published update. It satisfies contracts.Gorcure so it can replace the real publisher in tests.

func New

func New() *Gorcure

New returns an empty mock publisher.

func (*Gorcure) Count

func (m *Gorcure) Count() int

Count returns how many updates were recorded.

func (*Gorcure) Last

func (m *Gorcure) Last() (contracts.Update, bool)

Last returns the most recently recorded update and whether one exists.

func (*Gorcure) Publish

func (m *Gorcure) Publish(topic string, data any) (string, error)

Publish records a single-topic update.

func (*Gorcure) PublishUpdate

func (m *Gorcure) PublishUpdate(update contracts.Update) (string, error)

PublishUpdate records the update (unless Err is set) and returns the fake id.

Jump to

Keyboard shortcuts

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