Documentation
¶
Index ¶
Constants ¶
This section is empty.
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", } )
Functions ¶
This section is empty.
Types ¶
type Assertions ¶ added in v1.9.0
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() 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 // Terminal returns true if re-executing the Assertions against the same // result would be pointless. This allows Assertions to inform the Spec // that retrying the same operation would not be necessary. Terminal() bool }
Assertions track zero or more assertions about some result
type Defaults ¶ added in v1.7.0
type Defaults map[string]interface{}
Defaults are a collection of default configuration values
type Fixture ¶
type Fixture interface { // Start sets up the fixture Start() // Stop tears down the fixture, cleaning up any owned resources Stop() // 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 ¶ added in v1.10.1
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 ¶ added in v1.10.1
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 ¶ added in v1.10.1
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() []TestUnit }
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 }
PluginInfo contains basic information about the plugin and what type of tests it can handle.
type Runnable ¶
Runnable represents things that have a Run() method that accepts a Context and a pointer to a testing.T. Example things that implement this interface are `gdtcore.scenario.Scenario`, `gdtcore.spec.Spec` and `gdtcore.suite.Suite`.
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"` }
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.
func (*Spec) Title ¶
Title returns the Name of the scenario or the Path's file/base name if there is no name.
func (*Spec) UnmarshalYAML ¶ added in v1.7.0
UnmarshalYAML examines the mapping YAML node for base Spec fields and sets the associated struct field from that value node.
type TestUnit ¶ added in v1.7.0
type TestUnit interface { Runnable // SetBase sets the TestUnit's base Spec SetBase(Spec) // Base returns the TestUnit's base Spec Base() *Spec }
TestUnit represents individual test units in a Scenario
type Timeout ¶ added in v1.2.0
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 ¶ added in v1.9.0
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 ¶ added in v1.9.0
AfterDuration returns the time duration of the Wait.After
func (*Wait) BeforeDuration ¶ added in v1.9.0
BeforeDuration returns the time duration of the Wait.Before