tester

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 6 Imported by: 30

Documentation

Overview

Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. For newer features and behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in the github.com/open-policy-agent/opa/v1 package instead. See https://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information.

Package tester contains utilities for executing Rego tests.

Index

Constants

View Source
const SkipTestPrefix = v1.SkipTestPrefix

SkipTestPrefix declares the prefix for tests that should be skipped.

View Source
const TestPrefix = v1.TestPrefix

TestPrefix declares the prefix for all test rules.

Variables

This section is empty.

Functions

func Load added in v0.5.9

func Load(args []string, filter loader.Filter) (map[string]*ast.Module, storage.Store, error)

Load returns modules and an in-memory store for running tests.

func LoadBundles added in v0.14.0

func LoadBundles(args []string, filter loader.Filter) (map[string]*bundle.Bundle, error)

LoadBundles will load the given args as bundles, either tarball or directory is OK.

func LoadBundlesWithRegoVersion added in v0.60.0

func LoadBundlesWithRegoVersion(args []string, filter loader.Filter, regoVersion ast.RegoVersion) (map[string]*bundle.Bundle, error)

LoadBundlesWithRegoVersion will load the given args as bundles, either tarball or directory is OK. Bundles are parsed in accordance with the given RegoVersion.

func LoadWithRegoVersion added in v0.60.0

func LoadWithRegoVersion(args []string, filter loader.Filter, regoVersion ast.RegoVersion) (map[string]*ast.Module, storage.Store, error)

LoadWithRegoVersion returns modules and an in-memory store for running tests. Modules are parsed in accordance with the given RegoVersion.

Types

type BenchmarkOptions added in v0.18.0

type BenchmarkOptions = v1.BenchmarkOptions

BenchmarkOptions defines options specific to benchmarking tests

type Builtin added in v0.37.0

type Builtin = v1.Builtin

type JSONCoverageReporter added in v0.8.0

type JSONCoverageReporter = v1.JSONCoverageReporter

JSONCoverageReporter reports coverage as a JSON structure.

type JSONReporter added in v0.8.0

type JSONReporter = v1.JSONReporter

JSONReporter reports test results as array of JSON objects.

type PrettyReporter

type PrettyReporter = v1.PrettyReporter

PrettyReporter reports test results in a simple human readable format.

type Reporter added in v0.8.0

type Reporter = v1.Reporter

Reporter defines the interface for reporting test results.

type Result

type Result = v1.Result

Result represents a single test case result.

func Run

func Run(ctx context.Context, paths ...string) ([]*Result, error)

Run executes all test cases found under files in path.

func RunWithFilter added in v0.8.2

func RunWithFilter(ctx context.Context, _ loader.Filter, paths ...string) ([]*Result, error)

RunWithFilter executes all test cases found under files in path. The filter will be applied to exclude files that should not be included.

type Runner

type Runner = v1.Runner

Runner implements simple test discovery and execution.

func NewRunner

func NewRunner() *Runner

NewRunner returns a new runner.

Jump to

Keyboard shortcuts

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