test

package
v0.0.0-...-bf33661 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must(t *testing.T, err error)

Must is a test assertion to test for success.

func MustFail

func MustFail(t *testing.T, actual error, expected string)

MustFail is a test assertion to test for a specific error message.

func WithAPI

func WithAPI(params *setupParams)

WithAPI is a SetupOption that provides a http.Handler with the Tenso API.

func WithTaskContext

func WithTaskContext(params *setupParams)

WithTaskContext is a SetupOption that provides a tasks.Context object for testing worker tasks.

Types

type Setup

type Setup struct {
	// fields that are always set
	Clock    *mock.Clock
	Config   tenso.Configuration
	DB       *gorp.DbMap
	Ctx      context.Context //nolint: containedctx  // only used in tests
	Registry *prometheus.Registry
	// fields that are set if WithAPI is included
	Validator *mock.Validator[*mock.Enforcer]
	Handler   http.Handler
	// fields that are set if WithTaskContext is included
	TaskContext *tasks.Context
}

Setup contains all the pieces that are needed for most tests.

func NewSetup

func NewSetup(t *testing.T, opts ...SetupOption) Setup

NewSetup prepares most or all pieces of Tenso for a test.

type SetupOption

type SetupOption func(*setupParams)

SetupOption is an option that can be given to NewSetup().

func WithRoute

func WithRoute(route string) SetupOption

WithRoute is a SetupOption that adds a route to the configuration.

Jump to

Keyboard shortcuts

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