apitest

package
v0.1.21 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(ctx context.Context) (api.Client, error)

NewClient returns a new API client from the default configuration.

func WithUserAgent added in v0.0.27

func WithUserAgent(ctx context.Context, ua string) context.Context

WithUserAgent updates the value of the User-Agent header to send with the supplied context.

Types

type ApplicationTestDefinition added in v0.0.15

type ApplicationTestDefinition struct {
	Application applications.Application
	Scenario    applications.Scenario

	// In addition to the application and scenario, we need an experiment.
	ExperimentTestDefinition
}

ApplicationTestDefinition is used to define tests to run against an application API implementation.

func ReadApplicationTestData added in v0.0.15

func ReadApplicationTestData(path string) ([]ApplicationTestDefinition, error)

ReadApplicationTestData reads all of the JSON files in the supplied test data directory.

func (*ApplicationTestDefinition) GenerateTemplate added in v0.0.15

func (td *ApplicationTestDefinition) GenerateTemplate() applications.Template

GenerateTemplate returns details of experiment for this test definition.

type ExperimentTestDefinition added in v0.0.15

type ExperimentTestDefinition struct {
	// The name of the experiment to create during the test.
	ExperimentName experiments.ExperimentName
	// The experiment definition for testing.
	Experiment experiments.Experiment
	// A list of assignments for the baseline trial. May be empty to skip baseline trial tests.
	Baseline []experiments.Assignment
	// A matrix of weights used to map a vector of parameter assignments to a vector of metric values.
	Values [][]float64
	// The list of conditions to report as a failure.
	Failures []struct {
		// The parameter or metric name (assumes they never conflict).
		Name string
		// The optional minimum value to trigger the failure.
		Min *float64
		// The optional maximum value to trigger the failure.
		Max *float64
		// The failure reason to report when the condition is triggered.
		Reason string
		// The failure message to report when the condition is triggered.
		Message string
	}
}

ExperimentTestDefinition is used to define tests to run against an experiments API implementation.

func ReadExperimentsTestData added in v0.0.15

func ReadExperimentsTestData(path string) ([]ExperimentTestDefinition, error)

ReadExperimentsTestData reads all of the JSON files in the supplied test data directory.

func (*ExperimentTestDefinition) TrialResults added in v0.0.15

TrialResults computes dummy trial results for the supplied assignments.

Jump to

Keyboard shortcuts

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