tester

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextFile

type ContextFile struct {
	Path string `yaml:"path"`
}

ContextFile references an external JSON or YAML file for context.

type ContextValue

type ContextValue struct {
	Name  string `yaml:"name"`
	Value any    `yaml:"value"`
}

ContextValue is an inline context key-value pair.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner executes test cases. All relative paths are resolved against baseDir.

func NewRunner

func NewRunner(baseDir string) *Runner

NewRunner creates a runner with the given base directory.

func (*Runner) RunSuite

func (r *Runner) RunSuite(ctx context.Context, suite *TestSuite) *SuiteResult

RunSuite runs all tests in a suite and returns a SuiteResult.

func (*Runner) RunTest

func (r *Runner) RunTest(ctx context.Context, tc *TestCase) *TestResult

RunTest executes a single test case and returns the result.

type SuiteResult

type SuiteResult struct {
	Results  []TestResult
	Passed   int
	Failed   int
	Errors   int
	Duration time.Duration
}

SuiteResult captures the outcome of an entire test suite.

type TestCase

type TestCase struct {
	Name         string         `yaml:"name"`
	Policy       string         `yaml:"policy"`
	Expect       string         `yaml:"expect"` // "PASS" or "FAIL"
	Subject      string         `yaml:"subject"`
	Attestations []string       `yaml:"attestations"`
	Context      []ContextValue `yaml:"context"`
	ContextFiles []ContextFile  `yaml:"context-files"`
}

TestCase defines a single policy test.

type TestResult

type TestResult struct {
	Name     string
	Expected string // "PASS" or "FAIL"
	Actual   string // "PASS", "FAIL", "SOFTFAIL", "ERROR"
	Passed   bool
	Error    error
	Duration time.Duration
}

TestResult captures the outcome of a single test case.

type TestSuite

type TestSuite struct {
	Tests []TestCase `yaml:"tests"`
}

TestSuite holds all test cases loaded from a config file.

func LoadConfig

func LoadConfig(configPath string) (*TestSuite, error)

LoadConfig reads, parses, and validates a test config file.

func (*TestSuite) Validate

func (s *TestSuite) Validate() error

Validate checks that the suite has valid test cases.

Jump to

Keyboard shortcuts

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