types

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

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
}

Assertions track zero or more assertions about some result

type Defaults

type Defaults map[string]interface{}

Defaults are a collection of default configuration values

func (*Defaults) For

func (d *Defaults) For(key string) interface{}

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()
	// 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

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
}

PluginInfo contains basic information about the plugin and what type of tests it can handle.

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

func (s *Spec) Title() string

Title returns the Name of the scenario or the Path's file/base name if there is no name.

func (*Spec) UnmarshalYAML

func (s *Spec) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML examines the mapping YAML node for base Spec fields and sets the associated struct field from that value node.

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.

func (*Timeout) Duration

func (t *Timeout) Duration() time.Duration

Duration returns the time duration of the Timeout

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

func (w *Wait) AfterDuration() time.Duration

AfterDuration returns the time duration of the Wait.After

func (*Wait) BeforeDuration

func (w *Wait) BeforeDuration() time.Duration

BeforeDuration returns the time duration of the Wait.Before

Jump to

Keyboard shortcuts

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