et

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package et stands for Encore Tests and provides a number of functions and tools for writing fully integrated test suites for Encore applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OverrideAuthInfo added in v1.10.1

func OverrideAuthInfo(uid auth.UID, data any)

OverrideAuthInfo overrides the auth information for the current request. Subsequent calls to auth.UserID and auth.Data() within the same request will return the given uid and data, and API calls made from the request will propagate the newly set user info.

Passing in an empty string as the uid results in unsetting the auth information, causing future API calls to behave as if there was no authenticated user.

If the application's auth handler returns custom auth data, two additional requirements exist. First, the data parameter passed to WithContext must be of the same type as the auth handler returns. Second, if the uid argument is not the empty string then data may not be nil. If these requirements are not met, API calls made with these options will not be made and will immediately return a client-side error.

OverrideAuthInfo is not safe for concurrent use with code that invokes auth.UserID or auth.Data() within the same request.

func SetCfg added in v1.9.0

func SetCfg[T any](cfg config.Value[T], newValue T)

SetCfg changes the value of cfg to newValue within the current test and any subtests. Other tests running will not be affected.

It does not support setting slices and panics if given a config value that is a slice.

Types

type TopicHelpers

type TopicHelpers[T any] interface {
	// PublishedMessages returns a slice of all messages published during this test on this topic.
	PublishedMessages() []T
}

TopicHelpers provides functions for interacting with the backing topic implementation during unit tests. It is designed to help test code that uses the pubsub.Topic

Note all functions on this TopicHelpers are scoped to the current test and will only impact and observe state from the current test

func Topic

func Topic[T any](topic *pubsub.Topic[T]) (_ TopicHelpers[T])

Topic returns a TopicHelper for the given topic.

Jump to

Keyboard shortcuts

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