apptest

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestApplicationConfigFS embed.FS
View Source
var TestBootstrapConfigFS embed.FS
View Source
var TestDefaultConfigFS embed.FS

Functions

func Bootstrap

func Bootstrap() test.Options

Bootstrap is an entrypoint test.Options that indicates all sub tests should be run within the scope of an slim version of bootstrap.App

func NewFxTestRunner

func NewFxTestRunner() test.InternalRunner

NewFxTestRunner is internal use only, exported for cross-package reference

func NewTestConfigProvider

func NewTestConfigProvider(kvs map[string]interface{}) *testConfigProvider

NewTestConfigProvider is for internal usage. Export for cross-package reference Use WithConfigFS, WithProperties, WithDynamicProperties instead

func TestBootstrapper

func TestBootstrapper(ctx context.Context) *bootstrap.Bootstrapper

TestBootstrapper returns current *bootstrap.Bootstrapper of the test context

func WithBootstrapConfigFS

func WithBootstrapConfigFS(fs ...embed.FS) test.Options

WithBootstrapConfigFS provides per-test config capability. It register an embed.FS as bootstrap config, in which properties like "config.file.search-path" can be overridden. the given embed.FS should contains at least one yml file. see appconfig.FxEmbeddedBootstrapAdHoc

func WithConfigFS

func WithConfigFS(fs ...embed.FS) test.Options

WithConfigFS provides per-test config capability. It register an embed.FS as application config, which could override any defaults. the given embed.FS should contains at least one yml file see appconfig.FxEmbeddedApplicationAdHoc

func WithConfigFxProvider

func WithConfigFxProvider(fxProvides ...interface{}) test.Options

WithConfigFxProvider provides per-test config capability. It takes a fx.Option (usually fx.Provide) that returns/create appconfig.Provider and registers it as ad-hoc test application config provider. Note: Use it with caution. This is an advanced use case which typically used by other utility packages.

func WithDI

func WithDI(diTargets ...interface{}) test.Options

WithDI populate given di targets by using fx.Populate all targets need to be pointer to struct, otherwise the test fails See fx.Populate for more information

func WithDynamicProperties

func WithDynamicProperties(valuers map[string]PropertyValuerFunc) test.Options

WithDynamicProperties provides per-test config capability. It registers ad-hoc test application properties

func WithFxOptions

func WithFxOptions(opts ...fx.Option) test.Options

WithFxOptions register given fx.Option to test app as regular steps see bootstrap.Module

func WithFxPriorityOptions

func WithFxPriorityOptions(opts ...fx.Option) test.Options

WithFxPriorityOptions register given fx.Option to test app as priority steps, before any other modules see bootstrap.Module

func WithModules

func WithModules(modules ...*bootstrap.Module) test.Options

WithModules register given modules to test app

func WithProperties

func WithProperties(kvs ...string) test.Options

WithProperties provides per-test config capability. It registers ad-hoc test application properties. Supported format of each Key-Value pair are:

  • "dotted.properties=value"
  • "dotted.properties: value"
  • "dotted.properties.without.value" implies the value is "true"

func WithTimeout

func WithTimeout(timeout time.Duration) test.Options

WithTimeout specify expected test timeout to prevent blocking test process permanently

Types

type PropertyValuerFunc

type PropertyValuerFunc func(ctx context.Context) interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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