Documentation ¶
Overview ¶
Package schema provides the test scenario data schema for scenarigo.
Index ¶
- func WithInputConfig(root string, c InputConfig) func(*loadOption) error
- type Bind
- type Config
- type Duration
- type InputConfig
- type JSONReportConfig
- type JUnitReportConfig
- type LoadOption
- type OrderedMap
- func (m *OrderedMap[K, V]) Delete(key K) bool
- func (m OrderedMap[K, V]) Get(key K) (V, bool)
- func (m OrderedMap[K, V]) IsZero() bool
- func (m OrderedMap[K, V]) Len() int
- func (m OrderedMap[K, V]) MarshalYAML() ([]byte, error)
- func (m *OrderedMap[K, V]) Set(key K, value V)
- func (m OrderedMap[K, V]) ToMap() map[K]V
- func (m OrderedMap[K, V]) ToSlice() []OrderedMapItem[K, V]
- func (m *OrderedMap[K, V]) UnmarshalYAML(b []byte) error
- type OrderedMapItem
- type OutputConfig
- type PluginConfig
- type Regexp
- type ReportConfig
- type RetryPolicy
- type RetryPolicyConstant
- type RetryPolicyExponential
- type Scenario
- type Step
- type YAMLInputConfig
- type YTT
- type YTTConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithInputConfig ¶ added in v0.15.0
func WithInputConfig(root string, c InputConfig) func(*loadOption) error
WithInputConfig is an option to specify input config.
Types ¶
type Bind ¶
type Bind struct {
Vars map[string]interface{} `yaml:"vars"`
}
Bind represents bindings of variables.
type Config ¶ added in v0.7.0
type Config struct { SchemaVersion string `yaml:"schemaVersion,omitempty"` Vars map[string]any `yaml:"vars,omitempty"` Scenarios []string `yaml:"scenarios,omitempty"` PluginDirectory string `yaml:"pluginDirectory,omitempty"` Plugins OrderedMap[string, PluginConfig] `yaml:"plugins,omitempty"` Input InputConfig `yaml:"input,omitempty"` Output OutputConfig `yaml:"output,omitempty"` // absolute path to the configuration file Root string `yaml:"-"` Comments yaml.CommentMap `yaml:"-"` }
Config represents a configuration.
func LoadConfig ¶ added in v0.7.0
LoadConfig loads a configuration from path.
type Duration ¶ added in v0.12.6
Duration represents the elapsed time.
func (*Duration) MarshalYAML ¶ added in v0.12.6
MarshalYAML implements yaml.BytesMarshaler interface.
func (*Duration) UnmarshalYAML ¶ added in v0.12.6
UnmarshalYAML implements yaml.BytesUnmarshaler interface.
type InputConfig ¶ added in v0.15.0
type InputConfig struct { Excludes []Regexp `yaml:"excludes,omitempty"` YAML YAMLInputConfig `yaml:"yaml,omitempty"` }
InputConfig represents an input configuration.
type JSONReportConfig ¶ added in v0.7.0
type JSONReportConfig struct {
Filename string `yaml:"filename,omitempty"`
}
JSONReportConfig represents a JSON report configuration.
type JUnitReportConfig ¶ added in v0.7.0
type JUnitReportConfig struct {
Filename string `yaml:"filename,omitempty"`
}
JUnitReportConfig represents a JUnit report configuration.
type LoadOption ¶ added in v0.15.0
type LoadOption func(*loadOption) error
LoadOption represents an option to load scenarios.
type OrderedMap ¶ added in v0.15.0
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedMap represents an order-preserving map.
func NewOrderedMap ¶ added in v0.15.0
func NewOrderedMap[K comparable, V any]() OrderedMap[K, V]
NewOrderedMap creates a new order-preserving map.
func (*OrderedMap[K, V]) Delete ¶ added in v0.15.0
func (m *OrderedMap[K, V]) Delete(key K) bool
Delete deletes a value by key.
func (OrderedMap[K, V]) Get ¶ added in v0.15.0
func (m OrderedMap[K, V]) Get(key K) (V, bool)
Get gets a value by key.
func (OrderedMap[K, V]) IsZero ¶ added in v0.15.0
func (m OrderedMap[K, V]) IsZero() bool
IsZero implements yaml.IsZeroer interface.
func (OrderedMap[K, V]) Len ¶ added in v0.15.0
func (m OrderedMap[K, V]) Len() int
Len returns the length of m.
func (OrderedMap[K, V]) MarshalYAML ¶ added in v0.15.0
func (m OrderedMap[K, V]) MarshalYAML() ([]byte, error)
MarshalYAML implements yaml.BytesMarshaler interface.
func (*OrderedMap[K, V]) Set ¶ added in v0.15.0
func (m *OrderedMap[K, V]) Set(key K, value V)
Set sets a key-value pair.
func (OrderedMap[K, V]) ToMap ¶ added in v0.15.0
func (m OrderedMap[K, V]) ToMap() map[K]V
ToMap returns m as a map.
func (OrderedMap[K, V]) ToSlice ¶ added in v0.15.0
func (m OrderedMap[K, V]) ToSlice() []OrderedMapItem[K, V]
ToSlice returns m as a slice.
func (*OrderedMap[K, V]) UnmarshalYAML ¶ added in v0.15.0
func (m *OrderedMap[K, V]) UnmarshalYAML(b []byte) error
UnmarshalYAML implements yaml.BytesUnmarshaler interface.
type OrderedMapItem ¶ added in v0.15.0
type OrderedMapItem[K, V any] struct { Key K Value V }
OrderedMapItem represents an item in order-preserving map.
type OutputConfig ¶ added in v0.7.0
type OutputConfig struct { Verbose bool `yaml:"verbose,omitempty"` Colored *bool `yaml:"colored,omitempty"` Summary bool `yaml:"summary,omitempty"` Report ReportConfig `yaml:"report,omitempty"` }
OutputConfig represents an output configuration.
type PluginConfig ¶ added in v0.9.0
type PluginConfig struct {
Src string `yaml:"src,omitempty"`
}
PluginConfig represents a plugin configuration.
type Regexp ¶ added in v0.15.0
Regexp represents a regular expression pattern.
func (Regexp) MarshalYAML ¶ added in v0.15.0
MarshalYAML implements yaml.BytesMarshaler interface.
func (*Regexp) UnmarshalYAML ¶ added in v0.15.0
UnmarshalYAML implements yaml.BytesUnmarshaler interface.
type ReportConfig ¶ added in v0.7.0
type ReportConfig struct { JSON JSONReportConfig `yaml:"json,omitempty"` JUnit JUnitReportConfig `yaml:"junit,omitempty"` }
ReportConfig represents a report configuration.
type RetryPolicy ¶
type RetryPolicy struct { Constant *RetryPolicyConstant `yaml:"constant,omitempty"` Exponential *RetryPolicyExponential `yaml:"exponential,omitempty"` }
RetryPolicy represents a retry policy.
type RetryPolicyConstant ¶
type RetryPolicyConstant struct { Interval *Duration `yaml:"interval,omitempty"` // default value is 1s MaxRetries *int `yaml:"maxRetries,omitempty"` // default value is 5, 0 means forever MaxElapsedTime *Duration `yaml:"maxElapsedTime,omitempty"` // default value is 0, 0 means forever }
RetryPolicyConstant represents a constant retry policy.
type RetryPolicyExponential ¶
type RetryPolicyExponential struct { InitialInterval *Duration `yaml:"initialInterval,omitempty"` // default value is 500ms Factor *float64 `yaml:"factor,omitempty"` // default value is 1.5 JitterFactor *float64 `yaml:"jitterFactor,omitempty"` // default value is 0.5 MaxInterval *Duration `yaml:"maxInterval,omitempty"` // default value is 60s MaxRetries *int `yaml:"maxRetries,omitempty"` // default value is 5, 0 means forever MaxElapsedTime *Duration `yaml:"maxElapsedTime,omitempty"` // default value is 0, 0 means forever }
RetryPolicyExponential represents a exponential retry policy.
type Scenario ¶
type Scenario struct { SchemaVersion string `yaml:"schemaVersion,omitempty"` Title string `yaml:"title,omitempty"` Description string `yaml:"description,omitempty"` Plugins map[string]string `yaml:"plugins,omitempty"` Vars map[string]interface{} `yaml:"vars,omitempty"` Steps []*Step `yaml:"steps,omitempty"` // The strict YAML decoder fails to decode if finds an unknown field. // Anchors is the field for enabling to define YAML anchors by avoiding the error. // This field doesn't need to hold some data because anchors expand by the decoder. Anchors anchors `yaml:"anchors,omitempty"` Node ast.Node `yaml:"-"` // contains filtered or unexported fields }
Scenario represents a test scenario.
func LoadScenarios ¶
func LoadScenarios(path string, opts ...LoadOption) ([]*Scenario, error)
LoadScenarios loads test scenarios from path.
func LoadScenariosFromReader ¶ added in v0.6.0
func LoadScenariosFromReader(r io.Reader, opts ...LoadOption) ([]*Scenario, error)
LoadScenariosFromReader loads test scenarios with io.Reader.
type Step ¶
type Step struct { ID string `yaml:"id,omitempty" validate:"alphanum"` Title string `yaml:"title,omitempty"` Description string `yaml:"description,omitempty"` If string `yaml:"if,omitempty"` ContinueOnError bool `yaml:"continueOnError,omitempty"` Vars map[string]interface{} `yaml:"vars,omitempty"` Protocol string `yaml:"protocol,omitempty"` Request protocol.Invoker `yaml:"request,omitempty"` Expect protocol.AssertionBuilder `yaml:"expect,omitempty"` Include string `yaml:"include,omitempty"` Ref interface{} `yaml:"ref,omitempty"` Bind Bind `yaml:"bind,omitempty"` Timeout *Duration `yaml:"timeout,omitempty"` PostTimeoutWaitingLimit *Duration `yaml:"postTimeoutWaitingLimit,omitempty"` Retry *RetryPolicy `yaml:"retry,omitempty"` }
Step represents a step of scenario.
func (*Step) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler interface.
type YAMLInputConfig ¶ added in v0.15.0
type YAMLInputConfig struct {
YTT YTTConfig `yaml:"ytt,omitempty"`
}
YAMLInputConfig represents a YAML file input configuration.