test

package
v0.0.4-beta Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package test provides public test helpers for setting up end-to-end and integration tests for the routing-service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestConsumer

func NewTestConsumer(
	subID string,
	client *pubsub.Client,
	logger zerolog.Logger,
) (messagepipeline.MessageConsumer, error)

NewTestConsumer creates a concrete GooglePubsubConsumer for testing purposes.

func NewTestFirestoreTokenFetcher

func NewTestFirestoreTokenFetcher(
	ctx context.Context,
	fsClient *firestore.Client,
	projectID string,
	logger zerolog.Logger,
) (cache.Fetcher[urn.URN, []routing.DeviceToken], error)

NewTestFirestoreTokenFetcher creates a URN-keyed fetcher for testing. It does this by creating a concrete, string-keyed Firestore fetcher and wrapping it in our URN adapter. This encapsulates the logic for the test.

func NewTestMessageStore

func NewTestMessageStore(
	fsClient *firestore.Client,
	logger zerolog.Logger,
) (routing.MessageStore, error)

NewTestMessageStore creates a concrete FirestoreStore for testing purposes.

func NewTestProducer

func NewTestProducer(topic *pubsub.Publisher) routing.IngestionProducer

NewTestProducer creates a concrete PubsubProducer for testing purposes.

func NewTestServer

func NewTestServer(
	t *testing.T,
	ctx context.Context,
	psClient *pubsub.Client,
	fsClient *firestore.Client,

	deps *routing.Dependencies,
) *httptest.Server

NewTestServer creates and starts a fully-functional instance of the routing service for use in end-to-end tests. It uses real Pub/Sub and Firestore clients connected to emulators, providing a high-fidelity test environment.

Types

type FirestoreTokenAdapter

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

FirestoreTokenAdapter is a helper that wraps a generic Firestore document fetcher and extracts the `Tokens` field from the returned struct.

func (*FirestoreTokenAdapter) Close

func (a *FirestoreTokenAdapter) Close() error

Close satisfies the cache.Fetcher interface.

func (*FirestoreTokenAdapter) Fetch

Fetch satisfies the cache.Fetcher[string, []routing.DeviceToken] interface.

type URNTokenFetcherAdapter

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

URNTokenFetcherAdapter is a test helper that wraps a string-keyed Fetcher to make it compatible with the URN-keyed Fetcher interface.

func NewURNTokenFetcherAdapter

func NewURNTokenFetcherAdapter(stringFetcher cache.Fetcher[string, []routing.DeviceToken]) *URNTokenFetcherAdapter

NewURNTokenFetcherAdapter is the constructor for the adapter.

func (*URNTokenFetcherAdapter) Close

func (a *URNTokenFetcherAdapter) Close() error

Close satisfies the cache.Fetcher interface.

func (*URNTokenFetcherAdapter) Fetch

Fetch satisfies the cache.Fetcher[urn.URN, []routing.DeviceToken] interface.

Jump to

Keyboard shortcuts

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