Documentation ¶
Overview ¶
Package ftltest contains test utilities for the ftl package.
Index ¶
- func Context(options ...Option) context.Context
- type Option
- func WhenVerb[Req any, Resp any](verb ftl.Verb[Req, Resp], ...) Option
- func WithCallsAllowedWithinModule() Option
- func WithConfig[T ftl.ConfigType](config ftl.ConfigValue[T], value T) Option
- func WithProjectFile(path string) Option
- func WithSecret[T ftl.SecretType](secret ftl.SecretValue[T], value T) Option
- type OptionsState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶ added in v0.201.0
type Option func(context.Context, *OptionsState) error
func WhenVerb ¶ added in v0.189.0
func WhenVerb[Req any, Resp any](verb ftl.Verb[Req, Resp], fake func(ctx context.Context, req Req) (resp Resp, err error)) Option
WhenVerb replaces an implementation for a verb
To be used when setting up a context for a test: ctx := ftltest.Context(
ftltest.WhenVerb(Example.Verb, func(ctx context.Context, req Example.Req) (Example.Resp, error) { ... }), ... other options
)
func WithCallsAllowedWithinModule ¶ added in v0.196.0
func WithCallsAllowedWithinModule() Option
WithCallsAllowedWithinModule allows tests to enable calls to all verbs within the current module
Any overrides provided by calling WhenVerb(...) will take precedence
func WithConfig ¶ added in v0.189.0
func WithConfig[T ftl.ConfigType](config ftl.ConfigValue[T], value T) Option
WithConfig sets a configuration for the current module
To be used when setting up a context for a test: ctx := ftltest.Context(
ftltest.WithConfig(exampleEndpoint, "https://example.com"), ... other options
)
func WithProjectFile ¶ added in v0.201.0
WithProjectFile loads config and secrets from a project file
To be used when setting up a context for a test: ctx := ftltest.Context(
ftltest.WithProjectFile("path/to/ftl-project.yaml"), ... other options
)
func WithSecret ¶ added in v0.189.0
func WithSecret[T ftl.SecretType](secret ftl.SecretValue[T], value T) Option
WithSecret sets a secret for the current module
To be used when setting up a context for a test: ctx := ftltest.Context(
ftltest.WithSecret(privateKey, "abc123"), ... other options
)
type OptionsState ¶ added in v0.201.0
type OptionsState struct {
// contains filtered or unexported fields
}