istio: Index | Files

package ilt

import ""


Package Files

fakebag.go tests.go


var TestData = []TestInfo{ /* 423 elements not displayed */


TestData contains the common set of tests that is used by various components of il.

type FakeBag Uses

type FakeBag struct {
    Attrs map[string]interface{}
    // contains filtered or unexported fields

FakeBag is a fake implementation of the Bag for testing purposes.

func NewFakeBag Uses

func NewFakeBag(attrs map[string]interface{}) *FakeBag

NewFakeBag creates a FakeBag and converts map[string]string to StringMap

func (*FakeBag) Clear Uses

func (b *FakeBag) Clear()

func (*FakeBag) Contains Uses

func (b *FakeBag) Contains(key string) bool

Contains returns true if the key is present in the bag.

func (*FakeBag) Done Uses

func (b *FakeBag) Done()

Done indicates the bag can be reclaimed.

func (*FakeBag) Get Uses

func (b *FakeBag) Get(name string) (interface{}, bool)

Get returns an attribute value.

func (*FakeBag) MapReference Uses

func (b *FakeBag) MapReference(attr, key string, cond attribute.Presence)

MapReference implements reference tracker interface

func (*FakeBag) Names Uses

func (b *FakeBag) Names() []string

Names return the names of all the attributes known to this bag.

func (*FakeBag) Reference Uses

func (b *FakeBag) Reference(string, attribute.Presence)

Reference implements reference tracker interface

func (*FakeBag) ReferenceTracker Uses

func (b *FakeBag) ReferenceTracker() attribute.ReferenceTracker

ReferenceTracker is not set

func (*FakeBag) ReferencedList Uses

func (b *FakeBag) ReferencedList() []string

ReferencedList returns the sorted list of attributes that were referenced. Attribute references through string maps are encoded as mapname[keyname]. Absent values are prefixed with "-".

func (*FakeBag) Restore Uses

func (b *FakeBag) Restore(attribute.ReferencedAttributeSnapshot)

func (*FakeBag) Snapshot Uses

func (b *FakeBag) Snapshot() (_ attribute.ReferencedAttributeSnapshot)

func (*FakeBag) String Uses

func (b *FakeBag) String() string

String is needed to implement the Bag interface.

type TestInfo Uses

type TestInfo struct {

    // E contains the expression that is being tested.
    E   string

    // IL contains the textual IL representation of code.
    IL  string

    // I contains the attribute bag used for testing.
    I   map[string]interface{}

    // R contains the expected result of a successful evaluation.
    R   interface{}

    // CEL contains the expected result for CEL interpreter (if distinct)
    CEL interface{}

    // Referenced contains a list of attributes that should be referenced. If nil, attribute
    // tracking checks will be skipped.
    Referenced []string

    // ReferencedCEL overrides Referenced field for CEL-specific differences
    ReferencedCEL []string

    // Err contains the expected error message prefix of a failed evaluation.
    Err string

    // AstErr contains the expected error message of a failed evaluation, during AST evaluation.
    AstErr string

    // CompileErr contains the expected error message for a failed compilation.
    CompileErr string

    // Fns field holds any additional function metadata that needs to be involved in the test.
    Fns []ast.FunctionMetadata

    // Externs holds any additional externs that should be used during evaluation.
    Externs map[string]interface{}

    // Type is the expected type of the expression upon successful compilation.
    Type descriptor.ValueType

    // SkipAst indicates that AST based evaluator should not be used for this test.
    Skipast bool

    // Use this test as a benchmark as well.
    Bench bool
    // contains filtered or unexported fields

TestInfo is a structure that contains detailed test information. Depending on the test type, various fields of the TestInfo struct will be used for testing purposes. For example, compiler can use E and IL to test expression => IL conversion, interpreter can use IL and I, R&Err for evaluation tests and the evaluator can use expression and I, R&Err to test evaluation.

func (*TestInfo) CheckEvaluationResult Uses

func (t *TestInfo) CheckEvaluationResult(r interface{}, err error) error

CheckEvaluationResult compares the given evaluation result and error against the one that is declared in test. Returns an error if there is a mismatch.

func (*TestInfo) CheckReferenced Uses

func (t *TestInfo) CheckReferenced(bag *FakeBag) bool

CheckReferenced will check to see if the set of referenced attributes is expected. If t.Referenced is nil then returns true.

func (*TestInfo) Conf Uses

func (t *TestInfo) Conf() map[string]*descriptor.AttributeManifest_AttributeInfo

Conf returns the global config to use for the test.

func (*TestInfo) TestName Uses

func (t *TestInfo) TestName() string

TestName is the name to use for the test.

Package ilt imports 11 packages (graph). Updated 2020-07-03. Refresh now. Tools for package owners.