Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assertion ¶
type Assertion struct {
Should string `yaml:"should"`
Expect string `yaml:"expect"`
// SourceLine is the 1-indexed line of this assertion's `should:` in spec.yaml.
// Populated by discovery; not parsed from YAML.
SourceLine int `yaml:"-"`
// Equality
ToEqual interface{} `yaml:"toEqual,omitempty"`
ToNotEqual interface{} `yaml:"toNotEqual,omitempty"`
// Numeric comparison
ToBeGreaterThan *float64 `yaml:"toBeGreaterThan,omitempty"`
ToBeLessThan *float64 `yaml:"toBeLessThan,omitempty"`
ToBeGreaterOrEqual *float64 `yaml:"toBeGreaterOrEqual,omitempty"`
ToBeLessOrEqual *float64 `yaml:"toBeLessOrEqual,omitempty"`
// String
ToContain string `yaml:"toContain,omitempty"`
ToNotContain string `yaml:"toNotContain,omitempty"`
ToStartWith string `yaml:"toStartWith,omitempty"`
ToEndWith string `yaml:"toEndWith,omitempty"`
ToNotStartWith string `yaml:"toNotStartWith,omitempty"`
ToNotEndWith string `yaml:"toNotEndWith,omitempty"`
ToMatch string `yaml:"toMatch,omitempty"`
// Existence
ToExist *bool `yaml:"toExist,omitempty"`
ToBeNull *bool `yaml:"toBeNull,omitempty"`
// Object
ToHaveKey string `yaml:"toHaveKey,omitempty"`
// Set membership
ToBeOneOf []interface{} `yaml:"toBeOneOf,omitempty"`
ToNotBeOneOf []interface{} `yaml:"toNotBeOneOf,omitempty"`
// Array
ToContainItem interface{} `yaml:"toContainItem,omitempty"`
ToHaveLength *int `yaml:"toHaveLength,omitempty"`
ToHaveMinLength *int `yaml:"toHaveMinLength,omitempty"`
ToHaveMaxLength *int `yaml:"toHaveMaxLength,omitempty"`
}
Assertion is a single RSpec-like check
func (*Assertion) HasAnyOperator ¶
HasAnyOperator returns true if the assertion has any operator set, including existence/null checks.
func (*Assertion) HasValueOperators ¶
HasValueOperators returns true if the assertion has any value-based operators set
type AssertionResult ¶
type AssertionResult struct {
Should string `json:"should" yaml:"should"`
Status Status `json:"status" yaml:"status"`
Expected interface{} `json:"expected,omitempty" yaml:"expected,omitempty"`
Actual interface{} `json:"actual,omitempty" yaml:"actual,omitempty"`
Error string `json:"error,omitempty" yaml:"error,omitempty"`
SourceLine int `json:"source_line,omitempty" yaml:"source_line,omitempty"`
}
AssertionResult is the result of a single assertion
type Config ¶
type Config struct {
TestDir string
Tags []string
Workers int
FailFast bool
Verbose bool
Quiet bool
PreRunTimeout time.Duration
// Output format flags (file paths; empty means skip)
JSONOutput string
YAMLOutput string
MarkdownOutput string
EMDOutput string
HTMLOutput string
JUnitOutput string
// GitHubAnnotations emits ::error file=...,line=...:: lines on stdout for
// failing assertions, so they appear inline in GitHub PR diffs. Auto-enabled
// when GITHUB_ACTIONS=true.
GitHubAnnotations bool
}
Config holds all CLI configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults
type CountMatcher ¶ added in v0.1.2
type CountMatcher struct {
ToEqual *int `yaml:"toEqual,omitempty"`
ToBeGreaterThan *int `yaml:"toBeGreaterThan,omitempty"`
ToBeLessThan *int `yaml:"toBeLessThan,omitempty"`
ToBeGreaterOrEqual *int `yaml:"toBeGreaterOrEqual,omitempty"`
ToBeLessOrEqual *int `yaml:"toBeLessOrEqual,omitempty"`
}
CountMatcher asserts on how many resources the block's selector matched. It is the way to express "exactly N", "at least N", or "none" — a plain describe block with no count still treats a zero-match selector as a failure.
func (*CountMatcher) HasOperator ¶ added in v0.1.2
func (c *CountMatcher) HasOperator() bool
HasOperator reports whether at least one count operator is set.
func (*CountMatcher) UnmarshalYAML ¶ added in v0.1.2
func (c *CountMatcher) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML accepts either an integer scalar shorthand (`count: 2`, meaning exactly 2) or a matcher object (`count: {toBeGreaterThan: 0}`).
type DescBlock ¶
type DescBlock struct {
Name string `yaml:"name"`
Select string `yaml:"select"`
Count *CountMatcher `yaml:"count,omitempty"`
It []Assertion `yaml:"it"`
// CountLine is the 1-indexed line of this block's `count:` key in spec.yaml.
// Populated by discovery; not parsed from YAML. Used for GitHub annotations.
CountLine int `yaml:"-"`
}
DescBlock groups related assertions under a selector
type DescribeResult ¶
type DescribeResult struct {
Name string `json:"name" yaml:"name"`
Select string `json:"select,omitempty" yaml:"select,omitempty"`
Status Status `json:"status" yaml:"status"`
Assertions []AssertionResult `json:"assertions" yaml:"assertions"`
}
DescribeResult is the result of one describe block
type ManifestResult ¶ added in v0.1.1
type ManifestResult struct {
Path string `json:"path" yaml:"path"`
Content string `json:"content" yaml:"content"`
Documents int `json:"documents" yaml:"documents"`
}
ManifestResult captures a manifest file as tested after pre_run rendering.
type Spec ¶
type Spec struct {
Name string `yaml:"name"`
Tags []string `yaml:"tags,omitempty"`
PreRun []string `yaml:"pre_run,omitempty"`
// Render lists shell commands whose stdout is captured and parsed as
// manifests to test — no file redirect or `mkdir manifests` needed. It
// accepts a single command (scalar) or a list. Rendered manifests are
// tested alongside any manifest files discovered on disk.
Render StringList `yaml:"render,omitempty"`
Describe []DescBlock `yaml:"describe"`
// SourceFile is the spec.yaml path. Populated by discovery; not parsed from YAML.
SourceFile string `yaml:"-"`
}
Spec represents a test specification file (spec.yaml)
type SpecResult ¶
type SpecResult struct {
Name string `json:"name" yaml:"name"`
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
Status Status `json:"status" yaml:"status"`
Duration time.Duration `json:"duration" yaml:"duration"`
Describes []DescribeResult `json:"describes,omitempty" yaml:"describes,omitempty"`
Error string `json:"error,omitempty" yaml:"error,omitempty"`
SourceFile string `json:"source_file,omitempty" yaml:"source_file,omitempty"`
SourceContent string `json:"source_content,omitempty" yaml:"source_content,omitempty"`
Manifests []ManifestResult `json:"manifests,omitempty" yaml:"manifests,omitempty"`
}
SpecResult is the result of one spec.yaml file
type StringList ¶ added in v0.1.2
type StringList []string
StringList is a []string that also unmarshals from a single scalar string, so spec authors can write either `render: helm template .` or a YAML list.
func (*StringList) UnmarshalYAML ¶ added in v0.1.2
func (s *StringList) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML accepts either a scalar string or a sequence of strings.
type SuiteResult ¶
type SuiteResult struct {
Specs []SpecResult `json:"specs" yaml:"specs"`
Summary Summary `json:"summary" yaml:"summary"`
}
SuiteResult is the top-level result of a full test run
type Summary ¶
type Summary struct {
TotalSpecs int `json:"total_specs" yaml:"total_specs"`
PassedSpecs int `json:"passed_specs" yaml:"passed_specs"`
FailedSpecs int `json:"failed_specs" yaml:"failed_specs"`
SkippedSpecs int `json:"skipped_specs" yaml:"skipped_specs"`
ErrorSpecs int `json:"error_specs" yaml:"error_specs"`
TotalAssertions int `json:"total_assertions" yaml:"total_assertions"`
PassedAssertions int `json:"passed_assertions" yaml:"passed_assertions"`
FailedAssertions int `json:"failed_assertions" yaml:"failed_assertions"`
Duration time.Duration `json:"duration" yaml:"duration"`
Success bool `json:"success" yaml:"success"`
Timestamp time.Time `json:"timestamp" yaml:"timestamp"`
}
Summary aggregates counts across the run