cases

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cases contains utilities for evaluation test cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set struct {
	Cases []TestCase `json:"cases"`
}

Set represents a collection of test cases.

func Load

func Load(path string) (Set, error)

Load returns a set of built-in test cases.

func MustLoad

func MustLoad(path string) Set

MustLoad returns a set of built-in test cases or panics if an error occurs.

func (Set) Sorted

func (s Set) Sorted() Set

Sorted returns a sorted copy of s.

type TestCase

type TestCase struct {
	Filename      string                    `json:"-"`                         // name of file that case was loaded from
	Note          string                    `json:"note"`                      // globally unique identifier for this test case
	Query         string                    `json:"query"`                     // policy query to execute
	Modules       []string                  `json:"modules,omitempty"`         // policies to test against
	Data          *map[string]interface{}   `json:"data,omitempty"`            // data to test against
	Input         *interface{}              `json:"input,omitempty"`           // parsed input data to use
	InputTerm     *string                   `json:"input_term,omitempty"`      // raw input data (serialized as a string, overrides input)
	WantDefined   *bool                     `json:"want_defined,omitempty"`    // expect query result to be defined (or not)
	WantResult    *[]map[string]interface{} `json:"want_result,omitempty"`     // expect query result (overrides defined)
	WantErrorCode *string                   `json:"want_error_code,omitempty"` // expect query error code (overrides result)
	WantError     *string                   `json:"want_error,omitempty"`      // expect query error message (overrides error code)
	SortBindings  bool                      `json:"sort_bindings,omitempty"`   // indicates that binding values should be treated as sets
	StrictError   bool                      `json:"strict_error,omitempty"`    // indicates that the error depends on strict builtin error mode
}

TestCase represents a single test case.

Jump to

Keyboard shortcuts

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