scenario

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultsKey is the key within the Defaults collection for
	// scenario defaults.
	DefaultsKey = "gdt.scenario"
)

Variables

This section is empty.

Functions

func FromBytes

func FromBytes(
	contents []byte,
	mods ...ScenarioModifier,
) (gdttypes.Runnable, error)

FromBytes returns a Scenario after parsing the supplied contents

func FromReader

func FromReader(
	r io.Reader,
	mods ...ScenarioModifier,
) (gdttypes.Runnable, error)

FromReader parses the supplied io.Reader and returns a Scenario representing the contents in the reader. Returns an error if any syntax or validation failed

Types

type Defaults

type Defaults struct {
	// Timeout has fields that represent the default timeout behaviour and
	// expectations to use for test specs in the scenario.
	Timeout *gdttypes.Timeout `yaml:"timeout,omitempty"`
}

Defaults is the scenario's defaults collection

func (*Defaults) UnmarshalYAML

func (d *Defaults) UnmarshalYAML(node *yaml.Node) error

type Scenario

type Scenario struct {
	// Path is the filepath to the test case.
	Path string `yaml:"-"`
	// Name is the short name for the test case. If empty, defaults to the base
	// filename in Path.
	Name string `yaml:"name,omitempty"`
	// Description is a description of the tests contained in the test case.
	Description string `yaml:"description,omitempty"`
	// Defaults contains any default configuration values for test specs
	// contained within the test scenario.
	//
	// During parsing, plugins are handed this raw data and asked to interpret
	// it into known configuration values for that plugin.
	Defaults map[string]interface{} `yaml:"defaults,omitempty"`
	// Require specifies an ordered list of fixtures the test case depends on.
	Require []string `yaml:"require,omitempty"`
	// Tests is the collection of test units in this test case. These will be
	// the fully parsed and materialized plugin Spec structs.
	Tests []gdttypes.TestUnit `yaml:"tests,omitempty"`
}

Scenario is a generalized gdt test case file. It contains a set of Runnable test units.

func New

func New(mods ...ScenarioModifier) *Scenario

New returns a new Scenario

func (*Scenario) Run

func (s *Scenario) Run(ctx context.Context, t *testing.T) error

Run executes the tests in the test scenario

func (*Scenario) Title

func (s *Scenario) Title() string

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

func (*Scenario) UnmarshalYAML

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

UnmarshalYAML is a custom unmarshaler that asks plugins for their known spec types and attempts to unmarshal test spec contents into those types.

type ScenarioModifier

type ScenarioModifier func(s *Scenario)

ScenarioModifier sets some value on the test scenario

func WithDefaults

func WithDefaults(defaults map[string]interface{}) ScenarioModifier

WithDefaults sets a test scenario's Defaults attribute

func WithDescription

func WithDescription(description string) ScenarioModifier

WithDescription sets a test scenario's Description attribute

func WithName

func WithName(name string) ScenarioModifier

WithName sets a test scenario's Name attribute

func WithPath

func WithPath(path string) ScenarioModifier

WithPath sets a test scenario's Path attribute

func WithRequires

func WithRequires(require []string) ScenarioModifier

WithRequires sets a test scenario's Requires attribute

Jump to

Keyboard shortcuts

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