tester

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FixtureError

type FixtureError struct {
	Fixture    string   // Fixture filename
	Expected   string   // Expected outcome (allow/deny)
	Violations []string // Policy violations found (empty if expected allow but got deny)
}

FixtureError describes a fixture test failure.

type FixtureResults

type FixtureResults struct {
	Total  int            // Total number of fixtures tested
	Passed int            // Number of passing fixtures
	Failed int            // Number of failing fixtures
	Errors []FixtureError // Error details for failing fixtures
}

FixtureResults contains fixture-based test results.

func RunFixtures

func RunFixtures(ctx context.Context, fixtureDir string, policyDir string) (*FixtureResults, error)

RunFixtures evaluates policies against JSON fixture inputs. Naming conventions:

  • Filenames with "_allow", "_valid", or starting with "valid" expect no violations
  • Filenames with "_deny", "_invalid", or starting with "invalid" expect violations

fixtureDir: directory containing JSON fixture files (can have platform subdirs) policyDir: directory containing Rego policies (can have platform subdirs)

type Results

type Results struct {
	Total  int      // Total number of tests
	Passed int      // Number of passing tests
	Failed int      // Number of failing tests
	Errors []string // Error messages from failing tests
}

Results contains policy test execution results.

func Run

func Run(ctx context.Context, files map[string]string) (*Results, error)

Run executes OPA policy unit tests. files is a map of filename -> source code. Returns test results or an error if tests cannot be executed.

Jump to

Keyboard shortcuts

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