mocks

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EndpointExtractor

type EndpointExtractor struct {
	// contains filtered or unexported fields
}

EndpointExtractor is a mock EndpointExtractor for testing. It records all events it receives and provides helper methods for test assertions.

func NewEndpointExtractor

func NewEndpointExtractor(name string) *EndpointExtractor

NewEndpointExtractor creates a new mock EndpointExtractor with the given name.

func (*EndpointExtractor) Extract

Extract records the event and returns any configured error.

func (*EndpointExtractor) GetEvents

func (m *EndpointExtractor) GetEvents() []fwkdl.EndpointEvent

GetEvents returns a copy of all recorded events.

func (*EndpointExtractor) Reset

func (m *EndpointExtractor) Reset()

Reset clears all recorded events.

func (*EndpointExtractor) TypedName

func (m *EndpointExtractor) TypedName() fwkplugin.TypedName

func (*EndpointExtractor) WithExtractError

func (m *EndpointExtractor) WithExtractError(err error) *EndpointExtractor

WithExtractError configures the extractor to return an error on Extract.

func (*EndpointExtractor) WithType

func (m *EndpointExtractor) WithType(typeName string) *EndpointExtractor

WithType overrides the extractor's TypedName().Type for tests that need distinct Types (e.g. covering yield-vs-bind branches in runtime.Configure).

type Extractor

type Extractor struct {
	// contains filtered or unexported fields
}

Extractor is a generic mock for the typed Extractor[PollInput[Metrics]] interface used by polling tests. It records call counts and optionally updates endpoint metrics on each Extract.

func NewPollingExtractor

func NewPollingExtractor(name string) *Extractor

NewPollingExtractor creates a mock extractor for polling data sources. The metrics-typed input matches the HTTPDataSource[Metrics] dispatcher used by polling integration tests.

func (*Extractor) CallCount

func (m *Extractor) CallCount() int

CallCount returns the number of times Extract was called.

func (*Extractor) Extract

func (*Extractor) GetCallCount

func (m *Extractor) GetCallCount() int

GetCallCount returns call count (thread-safe).

func (*Extractor) Reset

func (m *Extractor) Reset()

Reset clears the call count.

func (*Extractor) TypedName

func (m *Extractor) TypedName() fwkplugin.TypedName

Type uses m.name so instances look like distinct plugin types; HTTP source dedupes appends by Type.

func (*Extractor) WithExtractError

func (m *Extractor) WithExtractError(err error) *Extractor

WithExtractError configures the extractor to return an error.

func (*Extractor) WithMetricsUpdate

func (m *Extractor) WithMetricsUpdate(metrics *fwkdl.Metrics) *Extractor

WithMetricsUpdate configures the extractor to write metrics into the endpoint on each Extract. Passing nil disables the update.

type NotificationExtractor

type NotificationExtractor struct {
	// contains filtered or unexported fields
}

NotificationExtractor implements both Extractor and NotificationExtractor for testing. It records all events it receives and provides helper methods for test assertions.

func NewNotificationExtractor

func NewNotificationExtractor(name string) *NotificationExtractor

NewNotificationExtractor creates a new mock extractor with the given name.

func (*NotificationExtractor) Extract

Extract records the event and returns any configured error.

func (*NotificationExtractor) GVK

func (*NotificationExtractor) GetEvents

GetEvents returns an immutable snapshot of all recorded events. It is safe to call concurrently: the snapshot is copied under the internal lock, so callers can iterate the returned slice without holding any lock and without racing against concurrent ExtractNotification calls.

func (*NotificationExtractor) Reset

func (m *NotificationExtractor) Reset()

Reset clears all recorded events.

func (*NotificationExtractor) TypedName

func (m *NotificationExtractor) TypedName() fwkplugin.TypedName

func (*NotificationExtractor) WithExtractError

func (m *NotificationExtractor) WithExtractError(err error) *NotificationExtractor

WithExtractError configures the extractor to return an error on Extract.

func (*NotificationExtractor) WithGVK

WithGVK sets the GVK for the mock extractor.

Jump to

Keyboard shortcuts

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