Documentation
¶
Index ¶
Constants ¶
const ( // DefaultRetryAttempts indicates the default number of times to retry // retries when the plugin uses retries but has not specified a number of // attempts. DefaultRetryAttempts = 3 * time.Second // DefaultRetryConstantInterval indicates the default interval to use for // retries when the plugin uses retries but does not use exponential // backoff. DefaultRetryConstantInterval = 3 * time.Second )
Variables ¶
var ( // BaseSpecFields contains the list of base spec fields for plugin Spec // types to use in ignoring unknown fields. BaseSpecFields = []string{ "name", "description", "timeout", "wait", "retry", } )
Functions ¶
This section is empty.
Types ¶
type Assertions ¶
type Assertions interface {
// OK returns true if all contained assertions pass successfully, false
// otherwise. If false is returned, Failures() is guaranteed to be
// non-empty.
OK(context.Context) bool
// Fail appends a supplied error to the set of failed assertions
Fail(error)
// Failures returns a slice of failure messages indicating which assertions
// did not succeed.
Failures() []error
}
Assertions track zero or more assertions about some result
type Defaults ¶
type Defaults map[string]interface{}
Defaults are a collection of default configuration values
type Evaluable ¶ added in v1.1.0
type Evaluable interface {
// Eval performs an action and evaluates the results of that action,
// returning a Result that informs the Scenario about what failed or
// succeeded about the Evaluable's conditions.
Eval(context.Context, *testing.T) *result.Result
// SetBase sets the Evaluable's base Spec
SetBase(Spec)
// Base returns the Evaluable's base Spec
Base() *Spec
}
Evaluable represents individual test units in a Scenario
type Fixture ¶
type Fixture interface {
// Start sets up the fixture
Start(context.Context) error
// Stop tears down the fixture, cleaning up any owned resources
Stop(context.Context)
// HasState returns true if the fixture contains some state with the given
// key
HasState(string) bool
// State returns the state data at the given key, or nil if no such state
// key is managed by the fixture
State(string) interface{}
}
A Fixture allows state to be passed from setups
type FlexStrings ¶
type FlexStrings struct {
// contains filtered or unexported fields
}
FlexStrings is a struct used to parse an interface{} that can be either a string or a slice of strings.
func (*FlexStrings) UnmarshalYAML ¶
func (f *FlexStrings) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML is a custom unmarshaler that understands that the value of the FlexStrings can be either a string or a slice of strings.
func (*FlexStrings) Values ¶
func (f *FlexStrings) Values() []string
Values returns the contained collection of string values.
type Plugin ¶
type Plugin interface {
// Info returns a struct that describes what the plugin does
Info() PluginInfo
// Defaults returns a YAML Unmarshaler types that the plugin knows how
// to parse its defaults configuration with.
Defaults() yaml.Unmarshaler
// Specs returns a list of YAML Unmarshaler types that the plugin knows
// how to parse.
Specs() []Evaluable
}
Plugin is the driver interface for different types of gdt tests.
type PluginInfo ¶
type PluginInfo struct {
// Name is the primary name of the plugin
Name string
// Aliases is an optional set of aliased names for the plugin
Aliases []string
// Description describes what types of tests the plugin can handle.
Description string
// Retry is a Retry that should be used by default for test specs of this
// plugin.
Retry *Retry
}
PluginInfo contains basic information about the plugin and what type of tests it can handle.
type Retry ¶ added in v1.7.0
type Retry struct {
// Attempts is the number of times that the test unit should be retried in
// the event of assertion failure.
Attempts *int `yaml:"attempts,omitempty"`
// Interval is the amount of time that the plugin should wait before
// retrying the test unit in the event of assertion failure.
// Specify a duration using Go's time duration string.
// See https://pkg.go.dev/time#ParseDuration
Interval string `yaml:"interval,omitempty"`
// Exponential indicates that an exponential backoff should be applied to
// the retry. When true, the value of Interval, if any, is used as the
// initial interval for the backoff algoritm.
Exponential bool `yaml:"exponential,omitempty"`
}
Retry contains information about the number of attempts and interval duration with which a Plugin should re-run a Spec's action if the Spec's assertions fail.
func (*Retry) IntervalDuration ¶ added in v1.7.0
IntervalDuration returns the time duration of the Retry.Interval
type Spec ¶
type Spec struct {
// Defaults contains the parsed defaults for the Spec. These are injected
// by the scenario during parse.
Defaults *Defaults `yaml:"-"`
// Index within the scenario where this Spec is located
Index int `yaml:"-"`
// Name for the individual test unit
Name string `yaml:"name,omitempty"`
// Description of the test unit
Description string `yaml:"description,omitempty"`
// Timeout contains the timeout configuration for the Spec
Timeout *Timeout `yaml:"timeout,omitempty"`
// Wait contains the wait configuration for the Spec
Wait *Wait `yaml:"wait,omitempty"`
// Retry contains the retry configuration for the Spec
Retry *Retry `yaml:"retry,omitempty"`
}
Spec represents a single test action and one or more assertions about output or behaviour. All gdt plugins have their own Spec structs that inherit from this base struct.
type Timeout ¶
type Timeout struct {
// After is the amount of time that the test unit should complete within.
// Specify a duration using Go's time duration string.
// See https://pkg.go.dev/time#ParseDuration
After string `yaml:"after,omitempty"`
// Expected indicates whether the timeout is expected to be exceeded. This
// is mostly useful for unit testing of the timeout functionality itself.
Expected bool `yaml:"expected,omitempty"`
}
Timeout contains information about the duration within which a Spec should run along with whether a deadline exceeded/timeout error should be expected or not.
type Wait ¶
type Wait struct {
// Before is the amount of time that the test unit should wait before
// executing its action.
// Specify a duration using Go's time duration string.
// See https://pkg.go.dev/time#ParseDuration
Before string `yaml:"before,omitempty"`
// After is the amount of time that the test unit should wait after
// executing its action.
// Specify a duration using Go's time duration string.
// See https://pkg.go.dev/time#ParseDuration
After string `yaml:"after,omitempty"`
}
Wait contains information about the duration within which a Spec should run along with whether a deadline exceeded/timeout error should be expected or not.
func (*Wait) AfterDuration ¶
AfterDuration returns the time duration of the Wait.After
func (*Wait) BeforeDuration ¶
BeforeDuration returns the time duration of the Wait.Before