ftltest

package
v0.196.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ftltest contains test utilities for the ftl package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Context

func Context(options ...func(*Options) error) context.Context

Context suitable for use in testing FTL verbs with provided options

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)) func(*Options) error

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() func(*Options) error

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) func(*Options) error

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 WithSecret added in v0.189.0

func WithSecret[T ftl.SecretType](secret ftl.SecretValue[T], value T) func(*Options) error

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

)

Types

type Options added in v0.196.1

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

Jump to

Keyboard shortcuts

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