domain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 1 Imported by: 0

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

func (a *Assertion) HasAnyOperator() bool

HasAnyOperator returns true if the assertion has any operator set, including existence/null checks.

func (*Assertion) HasValueOperators

func (a *Assertion) HasValueOperators() bool

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
	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 DescBlock

type DescBlock struct {
	Name   string      `yaml:"name"`
	Select string      `yaml:"select"`
	It     []Assertion `yaml:"it"`
}

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 Spec

type Spec struct {
	Name     string      `yaml:"name"`
	Tags     []string    `yaml:"tags,omitempty"`
	PreRun   []string    `yaml:"pre_run,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)

func (*Spec) HasTag

func (s *Spec) HasTag(tags ...string) bool

HasTag returns true if the spec has at least one of the given tags

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"`
}

SpecResult is the result of one spec.yaml file

type Status

type Status string

Status represents the outcome of a test

const (
	StatusPassed  Status = "passed"
	StatusFailed  Status = "failed"
	StatusSkipped Status = "skipped"
	StatusError   Status = "error"
)

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

Jump to

Keyboard shortcuts

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