Documentation
¶
Overview ¶
Package test provides public test helpers for setting up end-to-end and integration tests for the routing-service.
Index ¶
- func NewTestConsumer(subID string, client *pubsub.Client, logger zerolog.Logger) (messagepipeline.MessageConsumer, error)
- func NewTestFirestoreTokenFetcher(ctx context.Context, fsClient *firestore.Client, projectID string, ...) (cache.Fetcher[urn.URN, []routing.DeviceToken], error)
- func NewTestMessageStore(fsClient *firestore.Client, logger zerolog.Logger) (routing.MessageStore, error)
- func NewTestProducer(topic *pubsub.Publisher) routing.IngestionProducer
- func NewTestServer(t *testing.T, ctx context.Context, psClient *pubsub.Client, ...) *httptest.Server
- type FirestoreTokenAdapter
- type URNTokenFetcherAdapter
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 ¶
func (a *FirestoreTokenAdapter) Fetch(ctx context.Context, key string) ([]routing.DeviceToken, error)
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 ¶
func (a *URNTokenFetcherAdapter) Fetch(ctx context.Context, key urn.URN) ([]routing.DeviceToken, error)
Fetch satisfies the cache.Fetcher[urn.URN, []routing.DeviceToken] interface.