package tester
import "github.com/open-policy-agent/opa/tester"
Package tester contains utilities for executing Rego tests.
Index ¶
- Constants
- type PrettyReporter
- type Result
- func Run(ctx context.Context, path ...string) ([]*Result, error)
- func (r Result) Pass() bool
- func (r *Result) String() string
- type Runner
Constants ¶
const TestPrefix = "test_"
TestPrefix declares the prefix for all rules.
Types ¶
type PrettyReporter ¶
PrettyReporter reports test results in a simple human readable format.
func (PrettyReporter) Report ¶
func (r PrettyReporter) Report(ch chan *Result) error
Report prints the test report to the reporter's output.
type Result ¶
type Result struct { Location *ast.Location `json:"location"` Package string `json:"package"` Name string `json:"name"` Fail *interface{} `json:"fail,omitempty"` Error error `json:"error,omitempty"` Duration time.Duration `json:"duration"` }
Result represents a single test case result.
func Run ¶
Run executes all test cases found under files in path.
func (Result) Pass ¶
Pass returns true if the test case passed.
func (*Result) String ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner implements simple test discovery and execution.
func NewRunner ¶
func NewRunner() *Runner
NewRunner returns a new runner.
func (*Runner) Modules ¶
func (r *Runner) Modules(ctx context.Context, modules map[string]*ast.Module) (ch chan *Result, err error)
Modules executes all tests contained in the specified modules.
func (*Runner) Paths ¶
Paths executes all tests contained in policies under the specified paths.
func (*Runner) SetCompiler ¶
SetCompiler sets the compiler used by the runner.
Source Files ¶
- Version
- v0.5.8
- Published
- Sep 15, 2017
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 4 minutes ago –
Tools for package owners.