tester

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 15 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"`
	// Collectors lists attestation collector init strings (e.g.
	// "fs:testdata/bundle"). Filesystem-backed collectors ("fs:") resolve
	// their path relative to the test file's directory. Collectors are an
	// alternative evidence source to Attestations and are required to test
	// policies whose evidence must be synthesized (e.g. signature
	// attestations built from bundles or detached signatures).
	Collectors []string `yaml:"collectors"`
	// Signers lists the accepted signer identities (identity slugs, e.g.
	// "sigstore::<issuer>::<identity>") passed to the verifier, equivalent to
	// the --signer flag. Required to exercise policies that gate on the signer.
	Signers      []string       `yaml:"signers"`
	Context      []ContextValue `yaml:"context"`
	ContextFiles []ContextFile  `yaml:"context-files"`
	// AmpelVersion is the minimum ampel version (semver, e.g. "v1.3.7") the
	// test needs. Harnesses that run tests against several ampel versions
	// skip the test on engines older than this (see RunsOn). Empty means the
	// test runs on any version.
	AmpelVersion string `yaml:"ampel-version"`
}

TestCase defines a single policy test.

func (*TestCase) RunsOn added in v0.1.1

func (tc *TestCase) RunsOn(ampelVersion string) bool

RunsOn reports whether the test case can run on the given ampel version.

A test without an AmpelVersion floor runs on any engine. When the engine version is unknown or not a semantic version (e.g. a development build reporting "(devel)"), the test is assumed to run: a development tree is expected to carry every feature the tests target. Module pseudo-versions compare as semver, so a build of a commit between two tags sorts between them and one ahead of the latest tag sorts below the next tag, which skips rather than fails tests floored at that next release.

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