tester

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Adopted from https://github.com/open-policy-agent/opa/blob/main/tester/reporter.go

Copyright 2017 The OPA Authors. All rights reserved. Use of this source code is governed by an Apache2 license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONReporter

type JSONReporter struct {
	Output io.Writer
}

JSONReporter reports test results as array of JSON objects.

func (JSONReporter) Report

func (r JSONReporter) Report(ch []*TestResult) error

Report prints the test report to the reporter's output.

type Manager

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

func NewManager

func NewManager(policyID string, client *authorizer.Client) *Manager

NewManager returns new test manager instance.

func (*Manager) Enum

func (tm *Manager) Enum(c *cc.CommonCtx) ([]string, error)

func (*Manager) List

func (tm *Manager) List(c *cc.CommonCtx) ([]*TestRule, error)

List tests for a given policy ID.

func (*Manager) Ping

func (tm *Manager) Ping(c *cc.CommonCtx) bool

func (*Manager) Run

func (tm *Manager) Run(c *cc.CommonCtx) ([]*TestResult, error)

Run tests for a given policy ID.

type PrettyReporter

type PrettyReporter struct {
	Output      io.Writer
	Verbose     bool
	FailureLine bool
}

PrettyReporter reports test results in a simple human readable format.

func (PrettyReporter) Report

func (r PrettyReporter) Report(ch []*TestResult) error

Report prints the test report to the reporter's output.

type Reporter

type Reporter interface {
	Report(ch []*TestResult) error
}

Reporter defines the interface for reporting test results.

type TestResult

type TestResult struct {
	Package  string        `json:"package"`
	Name     string        `json:"name"`
	Fail     bool          `json:"fail"`
	Error    error         `json:"error"`
	Skip     bool          `json:"skip"`
	Duration time.Duration `json:"duration"`
	Output   []string      `json:"output"`
}

func (*TestResult) Pass

func (tr *TestResult) Pass() bool

Pass returns true if the test case passed.

func (*TestResult) String

func (tr *TestResult) String() string

type TestRule

type TestRule struct {
	Package string `json:"package"`
	Name    string `json:"name"`
}

func (*TestRule) String

func (tr *TestRule) String() string

Jump to

Keyboard shortcuts

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