test

package
v1.36.11-2025110320484... Latest Latest
Warning

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

Go to latest
Published: unknown License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const InputContext_ContextExpr_case case_InputContext_InputContextKind = 2
View Source
const InputContext_ContextMessage_case case_InputContext_InputContextKind = 1
View Source
const InputContext_InputContextKind_not_set_case case_InputContext_InputContextKind = 0
View Source
const InputValue_Expr_case case_InputValue_Kind = 2
View Source
const InputValue_Kind_not_set_case case_InputValue_Kind = 0
View Source
const InputValue_Value_case case_InputValue_Kind = 1
View Source
const SimpleTest_AnyEvalErrors_case case_SimpleTest_ResultMatcher = 10
View Source
const SimpleTest_AnyUnknowns_case case_SimpleTest_ResultMatcher = 12
View Source
const SimpleTest_EvalError_case case_SimpleTest_ResultMatcher = 9
View Source
const SimpleTest_ResultMatcher_not_set_case case_SimpleTest_ResultMatcher = 0
View Source
const SimpleTest_TypedResult_case case_SimpleTest_ResultMatcher = 16
View Source
const SimpleTest_Unknown_case case_SimpleTest_ResultMatcher = 11
View Source
const SimpleTest_Value_case case_SimpleTest_ResultMatcher = 8
View Source
const TestOutput_EvalError_case case_TestOutput_ResultKind = 10
View Source
const TestOutput_ResultExpr_case case_TestOutput_ResultKind = 9
View Source
const TestOutput_ResultKind_not_set_case case_TestOutput_ResultKind = 0
View Source
const TestOutput_ResultValue_case case_TestOutput_ResultKind = 8
View Source
const TestOutput_Unknown_case case_TestOutput_ResultKind = 11

Variables

View Source
var File_cel_expr_conformance_test_simple_proto protoreflect.FileDescriptor
View Source
var File_cel_expr_conformance_test_suite_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type ErrorSetMatcher

type ErrorSetMatcher struct {

	// Success if we match any of these sets.
	Errors []*expr.ErrorSet `protobuf:"bytes,1,rep,name=errors,proto3" json:"errors,omitempty"`
	// contains filtered or unexported fields
}

Matches error results from Eval.

func (*ErrorSetMatcher) GetErrors

func (x *ErrorSetMatcher) GetErrors() []*expr.ErrorSet

func (*ErrorSetMatcher) ProtoMessage

func (*ErrorSetMatcher) ProtoMessage()

func (*ErrorSetMatcher) ProtoReflect

func (x *ErrorSetMatcher) ProtoReflect() protoreflect.Message

func (*ErrorSetMatcher) Reset

func (x *ErrorSetMatcher) Reset()

func (*ErrorSetMatcher) SetErrors

func (x *ErrorSetMatcher) SetErrors(v []*expr.ErrorSet)

func (*ErrorSetMatcher) String

func (x *ErrorSetMatcher) String() string

type ErrorSetMatcher_builder

type ErrorSetMatcher_builder struct {

	// Success if we match any of these sets.
	Errors []*expr.ErrorSet
	// contains filtered or unexported fields
}

func (ErrorSetMatcher_builder) Build

type InputContext

type InputContext struct {

	// The type of input context for the test case
	//
	// Types that are valid to be assigned to InputContextKind:
	//
	//	*InputContext_ContextMessage
	//	*InputContext_ContextExpr
	InputContextKind isInputContext_InputContextKind `protobuf_oneof:"input_context_kind"`
	// contains filtered or unexported fields
}

Input context proto for the test case

func (*InputContext) ClearContextExpr

func (x *InputContext) ClearContextExpr()

func (*InputContext) ClearContextMessage

func (x *InputContext) ClearContextMessage()

func (*InputContext) ClearInputContextKind

func (x *InputContext) ClearInputContextKind()

func (*InputContext) GetContextExpr

func (x *InputContext) GetContextExpr() string

func (*InputContext) GetContextMessage

func (x *InputContext) GetContextMessage() *anypb.Any

func (*InputContext) GetInputContextKind

func (x *InputContext) GetInputContextKind() isInputContext_InputContextKind

func (*InputContext) HasContextExpr

func (x *InputContext) HasContextExpr() bool

func (*InputContext) HasContextMessage

func (x *InputContext) HasContextMessage() bool

func (*InputContext) HasInputContextKind

func (x *InputContext) HasInputContextKind() bool

func (*InputContext) ProtoMessage

func (*InputContext) ProtoMessage()

func (*InputContext) ProtoReflect

func (x *InputContext) ProtoReflect() protoreflect.Message

func (*InputContext) Reset

func (x *InputContext) Reset()

func (*InputContext) SetContextExpr

func (x *InputContext) SetContextExpr(v string)

func (*InputContext) SetContextMessage

func (x *InputContext) SetContextMessage(v *anypb.Any)

func (*InputContext) String

func (x *InputContext) String() string

func (*InputContext) WhichInputContextKind

func (x *InputContext) WhichInputContextKind() case_InputContext_InputContextKind

type InputContext_ContextExpr

type InputContext_ContextExpr struct {
	// A context expression representing a context proto variable. The
	// fields of the input proto.Messages are used as top-level variables within
	// an Activation. The expression is evaluated using the cel environment
	// configured for the test suite.
	ContextExpr string `protobuf:"bytes,2,opt,name=context_expr,json=contextExpr,proto3,oneof"`
}

type InputContext_ContextMessage

type InputContext_ContextMessage struct {
	// A context message represents an input kind in the form of a proto
	// message whose type is defined at runtime.
	ContextMessage *anypb.Any `protobuf:"bytes,1,opt,name=context_message,json=contextMessage,proto3,oneof"`
}

type InputContext_builder

type InputContext_builder struct {

	// Fields of oneof InputContextKind:
	// A context message represents an input kind in the form of a proto
	// message whose type is defined at runtime.
	ContextMessage *anypb.Any
	// A context expression representing a context proto variable. The
	// fields of the input proto.Messages are used as top-level variables within
	// an Activation. The expression is evaluated using the cel environment
	// configured for the test suite.
	ContextExpr *string
	// contains filtered or unexported fields
}

func (InputContext_builder) Build

func (b0 InputContext_builder) Build() *InputContext

type InputValue

type InputValue struct {

	// The type of input value that can be used for a variable binding
	//
	// Types that are valid to be assigned to Kind:
	//
	//	*InputValue_Value
	//	*InputValue_Expr
	Kind isInputValue_Kind `protobuf_oneof:"kind"`
	// contains filtered or unexported fields
}

The input value for a variable binding

func (*InputValue) ClearExpr

func (x *InputValue) ClearExpr()

func (*InputValue) ClearKind

func (x *InputValue) ClearKind()

func (*InputValue) ClearValue

func (x *InputValue) ClearValue()

func (*InputValue) GetExpr

func (x *InputValue) GetExpr() string

func (*InputValue) GetKind

func (x *InputValue) GetKind() isInputValue_Kind

func (*InputValue) GetValue

func (x *InputValue) GetValue() *expr.Value

func (*InputValue) HasExpr

func (x *InputValue) HasExpr() bool

func (*InputValue) HasKind

func (x *InputValue) HasKind() bool

func (*InputValue) HasValue

func (x *InputValue) HasValue() bool

func (*InputValue) ProtoMessage

func (*InputValue) ProtoMessage()

func (*InputValue) ProtoReflect

func (x *InputValue) ProtoReflect() protoreflect.Message

func (*InputValue) Reset

func (x *InputValue) Reset()

func (*InputValue) SetExpr

func (x *InputValue) SetExpr(v string)

func (*InputValue) SetValue

func (x *InputValue) SetValue(v *expr.Value)

func (*InputValue) String

func (x *InputValue) String() string

func (*InputValue) WhichKind

func (x *InputValue) WhichKind() case_InputValue_Kind

type InputValue_Expr

type InputValue_Expr struct {
	// An expression which evaluates to the value of the variable binding.
	// The expression is evaluated using the same runtime environment as the
	// one used for evaluating the expression under test.
	Expr string `protobuf:"bytes,2,opt,name=expr,proto3,oneof"`
}

type InputValue_Value

type InputValue_Value struct {
	// A simple literal value for a variable binding
	Value *expr.Value `protobuf:"bytes,1,opt,name=value,proto3,oneof"`
}

type InputValue_builder

type InputValue_builder struct {

	// Fields of oneof Kind:
	// A simple literal value for a variable binding
	Value *expr.Value
	// An expression which evaluates to the value of the variable binding.
	// The expression is evaluated using the same runtime environment as the
	// one used for evaluating the expression under test.
	Expr *string
	// contains filtered or unexported fields
}

func (InputValue_builder) Build

func (b0 InputValue_builder) Build() *InputValue

type SimpleTest

type SimpleTest struct {

	// Required.  The name of the test, which should be unique in the test file.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// A description of the test.
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// Required.  The text of the CEL expression.
	Expr string `protobuf:"bytes,3,opt,name=expr,proto3" json:"expr,omitempty"`
	// Disables all macro expansion in parsing.
	DisableMacros bool `protobuf:"varint,4,opt,name=disable_macros,json=disableMacros,proto3" json:"disable_macros,omitempty"`
	// Disables the check phase.
	DisableCheck bool `protobuf:"varint,5,opt,name=disable_check,json=disableCheck,proto3" json:"disable_check,omitempty"`
	// Disables the evaluate phase.
	CheckOnly bool `protobuf:"varint,15,opt,name=check_only,json=checkOnly,proto3" json:"check_only,omitempty"`
	// The type environment to use for the check phase.
	TypeEnv []*expr.Decl `protobuf:"bytes,6,rep,name=type_env,json=typeEnv,proto3" json:"type_env,omitempty"`
	// The container for name resolution.
	Container string `protobuf:"bytes,13,opt,name=container,proto3" json:"container,omitempty"`
	// The locale to use for the evaluation phase.
	Locale string `protobuf:"bytes,14,opt,name=locale,proto3" json:"locale,omitempty"`
	// Variable bindings to use for the eval phase.
	Bindings map[string]*expr.ExprValue `` /* 143-byte string literal not displayed */
	// An unspecified result defaults to a matcher for the true boolean value.
	//
	// Types that are valid to be assigned to ResultMatcher:
	//
	//	*SimpleTest_Value
	//	*SimpleTest_TypedResult
	//	*SimpleTest_EvalError
	//	*SimpleTest_AnyEvalErrors
	//	*SimpleTest_Unknown
	//	*SimpleTest_AnyUnknowns
	ResultMatcher isSimpleTest_ResultMatcher `protobuf_oneof:"result_matcher"`
	// contains filtered or unexported fields
}

A test which should run the given CEL program through parsing, optionally through checking, then evaluation, with the results of the pipeline validated by the given result matcher.

func (*SimpleTest) ClearAnyEvalErrors

func (x *SimpleTest) ClearAnyEvalErrors()

func (*SimpleTest) ClearAnyUnknowns

func (x *SimpleTest) ClearAnyUnknowns()

func (*SimpleTest) ClearEvalError

func (x *SimpleTest) ClearEvalError()

func (*SimpleTest) ClearResultMatcher

func (x *SimpleTest) ClearResultMatcher()

func (*SimpleTest) ClearTypedResult

func (x *SimpleTest) ClearTypedResult()

func (*SimpleTest) ClearUnknown

func (x *SimpleTest) ClearUnknown()

func (*SimpleTest) ClearValue

func (x *SimpleTest) ClearValue()

func (*SimpleTest) GetAnyEvalErrors

func (x *SimpleTest) GetAnyEvalErrors() *ErrorSetMatcher

func (*SimpleTest) GetAnyUnknowns

func (x *SimpleTest) GetAnyUnknowns() *UnknownSetMatcher

func (*SimpleTest) GetBindings

func (x *SimpleTest) GetBindings() map[string]*expr.ExprValue

func (*SimpleTest) GetCheckOnly

func (x *SimpleTest) GetCheckOnly() bool

func (*SimpleTest) GetContainer

func (x *SimpleTest) GetContainer() string

func (*SimpleTest) GetDescription

func (x *SimpleTest) GetDescription() string

func (*SimpleTest) GetDisableCheck

func (x *SimpleTest) GetDisableCheck() bool

func (*SimpleTest) GetDisableMacros

func (x *SimpleTest) GetDisableMacros() bool

func (*SimpleTest) GetEvalError

func (x *SimpleTest) GetEvalError() *expr.ErrorSet

func (*SimpleTest) GetExpr

func (x *SimpleTest) GetExpr() string

func (*SimpleTest) GetLocale

func (x *SimpleTest) GetLocale() string

func (*SimpleTest) GetName

func (x *SimpleTest) GetName() string

func (*SimpleTest) GetResultMatcher

func (x *SimpleTest) GetResultMatcher() isSimpleTest_ResultMatcher

func (*SimpleTest) GetTypeEnv

func (x *SimpleTest) GetTypeEnv() []*expr.Decl

func (*SimpleTest) GetTypedResult

func (x *SimpleTest) GetTypedResult() *TypedResult

func (*SimpleTest) GetUnknown

func (x *SimpleTest) GetUnknown() *expr.UnknownSet

func (*SimpleTest) GetValue

func (x *SimpleTest) GetValue() *expr.Value

func (*SimpleTest) HasAnyEvalErrors

func (x *SimpleTest) HasAnyEvalErrors() bool

func (*SimpleTest) HasAnyUnknowns

func (x *SimpleTest) HasAnyUnknowns() bool

func (*SimpleTest) HasEvalError

func (x *SimpleTest) HasEvalError() bool

func (*SimpleTest) HasResultMatcher

func (x *SimpleTest) HasResultMatcher() bool

func (*SimpleTest) HasTypedResult

func (x *SimpleTest) HasTypedResult() bool

func (*SimpleTest) HasUnknown

func (x *SimpleTest) HasUnknown() bool

func (*SimpleTest) HasValue

func (x *SimpleTest) HasValue() bool

func (*SimpleTest) ProtoMessage

func (*SimpleTest) ProtoMessage()

func (*SimpleTest) ProtoReflect

func (x *SimpleTest) ProtoReflect() protoreflect.Message

func (*SimpleTest) Reset

func (x *SimpleTest) Reset()

func (*SimpleTest) SetAnyEvalErrors

func (x *SimpleTest) SetAnyEvalErrors(v *ErrorSetMatcher)

func (*SimpleTest) SetAnyUnknowns

func (x *SimpleTest) SetAnyUnknowns(v *UnknownSetMatcher)

func (*SimpleTest) SetBindings

func (x *SimpleTest) SetBindings(v map[string]*expr.ExprValue)

func (*SimpleTest) SetCheckOnly

func (x *SimpleTest) SetCheckOnly(v bool)

func (*SimpleTest) SetContainer

func (x *SimpleTest) SetContainer(v string)

func (*SimpleTest) SetDescription

func (x *SimpleTest) SetDescription(v string)

func (*SimpleTest) SetDisableCheck

func (x *SimpleTest) SetDisableCheck(v bool)

func (*SimpleTest) SetDisableMacros

func (x *SimpleTest) SetDisableMacros(v bool)

func (*SimpleTest) SetEvalError

func (x *SimpleTest) SetEvalError(v *expr.ErrorSet)

func (*SimpleTest) SetExpr

func (x *SimpleTest) SetExpr(v string)

func (*SimpleTest) SetLocale

func (x *SimpleTest) SetLocale(v string)

func (*SimpleTest) SetName

func (x *SimpleTest) SetName(v string)

func (*SimpleTest) SetTypeEnv

func (x *SimpleTest) SetTypeEnv(v []*expr.Decl)

func (*SimpleTest) SetTypedResult

func (x *SimpleTest) SetTypedResult(v *TypedResult)

func (*SimpleTest) SetUnknown

func (x *SimpleTest) SetUnknown(v *expr.UnknownSet)

func (*SimpleTest) SetValue

func (x *SimpleTest) SetValue(v *expr.Value)

func (*SimpleTest) String

func (x *SimpleTest) String() string

func (*SimpleTest) WhichResultMatcher

func (x *SimpleTest) WhichResultMatcher() case_SimpleTest_ResultMatcher

type SimpleTestFile deprecated

type SimpleTestFile struct {

	// Required.  The name of the file.  Should match the filename.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// A description of the file.
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// The contained sections.
	Section []*SimpleTestSection `protobuf:"bytes,3,rep,name=section,proto3" json:"section,omitempty"`
	// contains filtered or unexported fields
}

The format of a simple test file, expected to be stored in text format. A file is the unit of granularity for selecting conformance tests, so tests of optional features should be segregated into separate files.

Deprecated: Use cel.expr.conformance.test.Suite

func (*SimpleTestFile) GetDescription

func (x *SimpleTestFile) GetDescription() string

func (*SimpleTestFile) GetName

func (x *SimpleTestFile) GetName() string

func (*SimpleTestFile) GetSection

func (x *SimpleTestFile) GetSection() []*SimpleTestSection

func (*SimpleTestFile) ProtoMessage

func (*SimpleTestFile) ProtoMessage()

func (*SimpleTestFile) ProtoReflect

func (x *SimpleTestFile) ProtoReflect() protoreflect.Message

func (*SimpleTestFile) Reset

func (x *SimpleTestFile) Reset()

func (*SimpleTestFile) SetDescription

func (x *SimpleTestFile) SetDescription(v string)

func (*SimpleTestFile) SetName

func (x *SimpleTestFile) SetName(v string)

func (*SimpleTestFile) SetSection

func (x *SimpleTestFile) SetSection(v []*SimpleTestSection)

func (*SimpleTestFile) String

func (x *SimpleTestFile) String() string

type SimpleTestFile_builder

type SimpleTestFile_builder struct {

	// Required.  The name of the file.  Should match the filename.
	Name string
	// A description of the file.
	Description string
	// The contained sections.
	Section []*SimpleTestSection
	// contains filtered or unexported fields
}

func (SimpleTestFile_builder) Build

type SimpleTestSection

type SimpleTestSection struct {

	// Required.  The name of the section.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// A description of the section.
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// The contained tests.
	Test []*SimpleTest `protobuf:"bytes,3,rep,name=test,proto3" json:"test,omitempty"`
	// contains filtered or unexported fields
}

A collection of related SimpleTests.

The section is the unit of organization within a test file, and should guide where new tests are added.

func (*SimpleTestSection) GetDescription

func (x *SimpleTestSection) GetDescription() string

func (*SimpleTestSection) GetName

func (x *SimpleTestSection) GetName() string

func (*SimpleTestSection) GetTest

func (x *SimpleTestSection) GetTest() []*SimpleTest

func (*SimpleTestSection) ProtoMessage

func (*SimpleTestSection) ProtoMessage()

func (*SimpleTestSection) ProtoReflect

func (x *SimpleTestSection) ProtoReflect() protoreflect.Message

func (*SimpleTestSection) Reset

func (x *SimpleTestSection) Reset()

func (*SimpleTestSection) SetDescription

func (x *SimpleTestSection) SetDescription(v string)

func (*SimpleTestSection) SetName

func (x *SimpleTestSection) SetName(v string)

func (*SimpleTestSection) SetTest

func (x *SimpleTestSection) SetTest(v []*SimpleTest)

func (*SimpleTestSection) String

func (x *SimpleTestSection) String() string

type SimpleTestSection_builder

type SimpleTestSection_builder struct {

	// Required.  The name of the section.
	Name string
	// A description of the section.
	Description string
	// The contained tests.
	Test []*SimpleTest
	// contains filtered or unexported fields
}

func (SimpleTestSection_builder) Build

type SimpleTest_AnyEvalErrors

type SimpleTest_AnyEvalErrors struct {
	// Matches one of several error results.
	// (Using explicit message since oneof can't handle repeated.)
	AnyEvalErrors *ErrorSetMatcher `protobuf:"bytes,10,opt,name=any_eval_errors,json=anyEvalErrors,proto3,oneof"`
}

type SimpleTest_AnyUnknowns

type SimpleTest_AnyUnknowns struct {
	// Matches one of several unknown results.
	// (Using explicit message since oneof can't handle repeated.)
	AnyUnknowns *UnknownSetMatcher `protobuf:"bytes,12,opt,name=any_unknowns,json=anyUnknowns,proto3,oneof"`
}

type SimpleTest_EvalError

type SimpleTest_EvalError struct {
	// Matches error evaluation results.
	EvalError *expr.ErrorSet `protobuf:"bytes,9,opt,name=eval_error,json=evalError,proto3,oneof"`
}

type SimpleTest_TypedResult

type SimpleTest_TypedResult struct {
	// A result and deduced expression type.
	TypedResult *TypedResult `protobuf:"bytes,16,opt,name=typed_result,json=typedResult,proto3,oneof"`
}

type SimpleTest_Unknown

type SimpleTest_Unknown struct {
	// Matches unknown evaluation results.
	Unknown *expr.UnknownSet `protobuf:"bytes,11,opt,name=unknown,proto3,oneof"`
}

type SimpleTest_Value

type SimpleTest_Value struct {
	// A normal value, which must match the evaluation result exactly
	// via value equality semantics.  This coincides with proto equality,
	// except for:
	// *   maps are order-agnostic.
	// *   a floating point NaN should match any NaN.
	Value *expr.Value `protobuf:"bytes,8,opt,name=value,proto3,oneof"`
}

type SimpleTest_builder

type SimpleTest_builder struct {

	// Required.  The name of the test, which should be unique in the test file.
	Name string
	// A description of the test.
	Description string
	// Required.  The text of the CEL expression.
	Expr string
	// Disables all macro expansion in parsing.
	DisableMacros bool
	// Disables the check phase.
	DisableCheck bool
	// Disables the evaluate phase.
	CheckOnly bool
	// The type environment to use for the check phase.
	TypeEnv []*expr.Decl
	// The container for name resolution.
	Container string
	// The locale to use for the evaluation phase.
	Locale string
	// Variable bindings to use for the eval phase.
	Bindings map[string]*expr.ExprValue

	// Fields of oneof ResultMatcher:
	// A normal value, which must match the evaluation result exactly
	// via value equality semantics.  This coincides with proto equality,
	// except for:
	// *   maps are order-agnostic.
	// *   a floating point NaN should match any NaN.
	Value *expr.Value
	// A result and deduced expression type.
	TypedResult *TypedResult
	// Matches error evaluation results.
	EvalError *expr.ErrorSet
	// Matches one of several error results.
	// (Using explicit message since oneof can't handle repeated.)
	AnyEvalErrors *ErrorSetMatcher
	// Matches unknown evaluation results.
	Unknown *expr.UnknownSet
	// Matches one of several unknown results.
	// (Using explicit message since oneof can't handle repeated.)
	AnyUnknowns *UnknownSetMatcher
	// contains filtered or unexported fields
}

func (SimpleTest_builder) Build

func (b0 SimpleTest_builder) Build() *SimpleTest

type TestCase

type TestCase struct {

	// Name of the test case.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// A description of the test.
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// The text of the CEL expression.
	Expr string `protobuf:"bytes,3,opt,name=expr,proto3" json:"expr,omitempty"`
	// Serialized environment to be used for compilation and evaluation of the
	// CEL expression for the current test case.
	// This option allows validating the same expression against multiple
	// environments.
	Env *conformance.Environment `protobuf:"bytes,4,opt,name=env,proto3" json:"env,omitempty"`
	// A map representing a variable binding where the key is the name of the
	// input variable.
	Input map[string]*InputValue `` /* 137-byte string literal not displayed */
	// Input in the form of a context proto for the test case.
	// Note: Only one of `input_bindings` and `input_context` can be provided. Providing
	// both should result in an error.
	InputContext *InputContext `protobuf:"bytes,6,opt,name=input_context,json=inputContext,proto3" json:"input_context,omitempty"`
	// Expected result of the test case.
	Output *TestOutput `protobuf:"bytes,7,opt,name=output,proto3" json:"output,omitempty"`
	// If specified validates that the deduced type at check time matches
	// If the result kind is not set and this field is set, the test is considered
	// "check-only".
	DeducedType *expr.Type `protobuf:"bytes,8,opt,name=deduced_type,json=deducedType,proto3" json:"deduced_type,omitempty"`
	// Bypass the type-checking and only attempt to evaluate the parsed
	// expression.
	DisableCheck bool `protobuf:"varint,9,opt,name=disable_check,json=disableCheck,proto3" json:"disable_check,omitempty"`
	// contains filtered or unexported fields
}

A test to validate a CEL policy or expression. The test case encompasses evaluation of the compiled expression using the provided input bindings and asserting the result against the expected result. It can also validate a raw CEL expression string through parse, check and eval stages, making use of the augmenting CEL environment if provided.

func (*TestCase) ClearDeducedType

func (x *TestCase) ClearDeducedType()

func (*TestCase) ClearEnv

func (x *TestCase) ClearEnv()

func (*TestCase) ClearInputContext

func (x *TestCase) ClearInputContext()

func (*TestCase) ClearOutput

func (x *TestCase) ClearOutput()

func (*TestCase) GetDeducedType

func (x *TestCase) GetDeducedType() *expr.Type

func (*TestCase) GetDescription

func (x *TestCase) GetDescription() string

func (*TestCase) GetDisableCheck

func (x *TestCase) GetDisableCheck() bool

func (*TestCase) GetEnv

func (x *TestCase) GetEnv() *conformance.Environment

func (*TestCase) GetExpr

func (x *TestCase) GetExpr() string

func (*TestCase) GetInput

func (x *TestCase) GetInput() map[string]*InputValue

func (*TestCase) GetInputContext

func (x *TestCase) GetInputContext() *InputContext

func (*TestCase) GetName

func (x *TestCase) GetName() string

func (*TestCase) GetOutput

func (x *TestCase) GetOutput() *TestOutput

func (*TestCase) HasDeducedType

func (x *TestCase) HasDeducedType() bool

func (*TestCase) HasEnv

func (x *TestCase) HasEnv() bool

func (*TestCase) HasInputContext

func (x *TestCase) HasInputContext() bool

func (*TestCase) HasOutput

func (x *TestCase) HasOutput() bool

func (*TestCase) ProtoMessage

func (*TestCase) ProtoMessage()

func (*TestCase) ProtoReflect

func (x *TestCase) ProtoReflect() protoreflect.Message

func (*TestCase) Reset

func (x *TestCase) Reset()

func (*TestCase) SetDeducedType

func (x *TestCase) SetDeducedType(v *expr.Type)

func (*TestCase) SetDescription

func (x *TestCase) SetDescription(v string)

func (*TestCase) SetDisableCheck

func (x *TestCase) SetDisableCheck(v bool)

func (*TestCase) SetEnv

func (x *TestCase) SetEnv(v *conformance.Environment)

func (*TestCase) SetExpr

func (x *TestCase) SetExpr(v string)

func (*TestCase) SetInput

func (x *TestCase) SetInput(v map[string]*InputValue)

func (*TestCase) SetInputContext

func (x *TestCase) SetInputContext(v *InputContext)

func (*TestCase) SetName

func (x *TestCase) SetName(v string)

func (*TestCase) SetOutput

func (x *TestCase) SetOutput(v *TestOutput)

func (*TestCase) String

func (x *TestCase) String() string

type TestCase_builder

type TestCase_builder struct {

	// Name of the test case.
	Name string
	// A description of the test.
	Description string
	// The text of the CEL expression.
	Expr string
	// Serialized environment to be used for compilation and evaluation of the
	// CEL expression for the current test case.
	// This option allows validating the same expression against multiple
	// environments.
	Env *conformance.Environment
	// A map representing a variable binding where the key is the name of the
	// input variable.
	Input map[string]*InputValue
	// Input in the form of a context proto for the test case.
	// Note: Only one of `input_bindings` and `input_context` can be provided. Providing
	// both should result in an error.
	InputContext *InputContext
	// Expected result of the test case.
	Output *TestOutput
	// If specified validates that the deduced type at check time matches
	// If the result kind is not set and this field is set, the test is considered
	// "check-only".
	DeducedType *expr.Type
	// Bypass the type-checking and only attempt to evaluate the parsed
	// expression.
	DisableCheck bool
	// contains filtered or unexported fields
}

func (TestCase_builder) Build

func (b0 TestCase_builder) Build() *TestCase

type TestOutput

type TestOutput struct {

	// Type of expected result of the test case.
	//
	// Types that are valid to be assigned to ResultKind:
	//
	//	*TestOutput_ResultValue
	//	*TestOutput_ResultExpr
	//	*TestOutput_EvalError
	//	*TestOutput_Unknown
	ResultKind isTestOutput_ResultKind `protobuf_oneof:"result_kind"`
	// contains filtered or unexported fields
}

Expected result of the test case.

func (*TestOutput) ClearEvalError

func (x *TestOutput) ClearEvalError()

func (*TestOutput) ClearResultExpr

func (x *TestOutput) ClearResultExpr()

func (*TestOutput) ClearResultKind

func (x *TestOutput) ClearResultKind()

func (*TestOutput) ClearResultValue

func (x *TestOutput) ClearResultValue()

func (*TestOutput) ClearUnknown

func (x *TestOutput) ClearUnknown()

func (*TestOutput) GetEvalError

func (x *TestOutput) GetEvalError() *expr.ErrorSet

func (*TestOutput) GetResultExpr

func (x *TestOutput) GetResultExpr() string

func (*TestOutput) GetResultKind

func (x *TestOutput) GetResultKind() isTestOutput_ResultKind

func (*TestOutput) GetResultValue

func (x *TestOutput) GetResultValue() *expr.Value

func (*TestOutput) GetUnknown

func (x *TestOutput) GetUnknown() *expr.UnknownSet

func (*TestOutput) HasEvalError

func (x *TestOutput) HasEvalError() bool

func (*TestOutput) HasResultExpr

func (x *TestOutput) HasResultExpr() bool

func (*TestOutput) HasResultKind

func (x *TestOutput) HasResultKind() bool

func (*TestOutput) HasResultValue

func (x *TestOutput) HasResultValue() bool

func (*TestOutput) HasUnknown

func (x *TestOutput) HasUnknown() bool

func (*TestOutput) ProtoMessage

func (*TestOutput) ProtoMessage()

func (*TestOutput) ProtoReflect

func (x *TestOutput) ProtoReflect() protoreflect.Message

func (*TestOutput) Reset

func (x *TestOutput) Reset()

func (*TestOutput) SetEvalError

func (x *TestOutput) SetEvalError(v *expr.ErrorSet)

func (*TestOutput) SetResultExpr

func (x *TestOutput) SetResultExpr(v string)

func (*TestOutput) SetResultValue

func (x *TestOutput) SetResultValue(v *expr.Value)

func (*TestOutput) SetUnknown

func (x *TestOutput) SetUnknown(v *expr.UnknownSet)

func (*TestOutput) String

func (x *TestOutput) String() string

func (*TestOutput) WhichResultKind

func (x *TestOutput) WhichResultKind() case_TestOutput_ResultKind

type TestOutput_EvalError

type TestOutput_EvalError struct {
	// An error evaluation result set. Success if we match all of the errors in
	// the set.
	EvalError *expr.ErrorSet `protobuf:"bytes,10,opt,name=eval_error,json=evalError,proto3,oneof"`
}

type TestOutput_ResultExpr

type TestOutput_ResultExpr struct {
	// An expression to be evaluated using the cel environment configured for
	// the test suite. The result of this expression must match the result of
	// the test case.
	ResultExpr string `protobuf:"bytes,9,opt,name=result_expr,json=resultExpr,proto3,oneof"`
}

type TestOutput_ResultValue

type TestOutput_ResultValue struct {
	// A normal value, which must match the evaluation result exactly via value
	// equality semantics. This coincides with proto equality, except for:
	// *   maps are order-agnostic
	// *   a floating point NaN should match any NaN
	ResultValue *expr.Value `protobuf:"bytes,8,opt,name=result_value,json=resultValue,proto3,oneof"`
}

type TestOutput_Unknown

type TestOutput_Unknown struct {
	// An unknown evaluation result.
	Unknown *expr.UnknownSet `protobuf:"bytes,11,opt,name=unknown,proto3,oneof"`
}

type TestOutput_builder

type TestOutput_builder struct {

	// Fields of oneof ResultKind:
	// A normal value, which must match the evaluation result exactly via value
	// equality semantics. This coincides with proto equality, except for:
	// *   maps are order-agnostic
	// *   a floating point NaN should match any NaN
	ResultValue *expr.Value
	// An expression to be evaluated using the cel environment configured for
	// the test suite. The result of this expression must match the result of
	// the test case.
	ResultExpr *string
	// An error evaluation result set. Success if we match all of the errors in
	// the set.
	EvalError *expr.ErrorSet
	// An unknown evaluation result.
	Unknown *expr.UnknownSet
	// contains filtered or unexported fields
}

func (TestOutput_builder) Build

func (b0 TestOutput_builder) Build() *TestOutput

type TestSection

type TestSection struct {

	// Name of the test section.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Description of the test section.
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// Test cases of the test section.
	// Each test case represents a test scenario.
	Tests []*TestCase `protobuf:"bytes,3,rep,name=tests,proto3" json:"tests,omitempty"`
	// contains filtered or unexported fields
}

A collection of related test cases.

func (*TestSection) GetDescription

func (x *TestSection) GetDescription() string

func (*TestSection) GetName

func (x *TestSection) GetName() string

func (*TestSection) GetTests

func (x *TestSection) GetTests() []*TestCase

func (*TestSection) ProtoMessage

func (*TestSection) ProtoMessage()

func (*TestSection) ProtoReflect

func (x *TestSection) ProtoReflect() protoreflect.Message

func (*TestSection) Reset

func (x *TestSection) Reset()

func (*TestSection) SetDescription

func (x *TestSection) SetDescription(v string)

func (*TestSection) SetName

func (x *TestSection) SetName(v string)

func (*TestSection) SetTests

func (x *TestSection) SetTests(v []*TestCase)

func (*TestSection) String

func (x *TestSection) String() string

type TestSection_builder

type TestSection_builder struct {

	// Name of the test section.
	Name string
	// Description of the test section.
	Description string
	// Test cases of the test section.
	// Each test case represents a test scenario.
	Tests []*TestCase
	// contains filtered or unexported fields
}

func (TestSection_builder) Build

func (b0 TestSection_builder) Build() *TestSection

type TestSuite

type TestSuite struct {

	// The name of the test suite.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Description of the test suite.
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// Test sections of the test suite.
	// Each section represents a behavior to be tested.
	Sections []*TestSection `protobuf:"bytes,3,rep,name=sections,proto3" json:"sections,omitempty"`
	// contains filtered or unexported fields
}

A test suite is a collection of tests designed to evaluate the correctness of a CEL policy, a CEL expression or the conformance of a CEL implementation to the standard specification.

func (*TestSuite) GetDescription

func (x *TestSuite) GetDescription() string

func (*TestSuite) GetName

func (x *TestSuite) GetName() string

func (*TestSuite) GetSections

func (x *TestSuite) GetSections() []*TestSection

func (*TestSuite) ProtoMessage

func (*TestSuite) ProtoMessage()

func (*TestSuite) ProtoReflect

func (x *TestSuite) ProtoReflect() protoreflect.Message

func (*TestSuite) Reset

func (x *TestSuite) Reset()

func (*TestSuite) SetDescription

func (x *TestSuite) SetDescription(v string)

func (*TestSuite) SetName

func (x *TestSuite) SetName(v string)

func (*TestSuite) SetSections

func (x *TestSuite) SetSections(v []*TestSection)

func (*TestSuite) String

func (x *TestSuite) String() string

type TestSuite_builder

type TestSuite_builder struct {

	// The name of the test suite.
	Name string
	// Description of the test suite.
	Description string
	// Test sections of the test suite.
	// Each section represents a behavior to be tested.
	Sections []*TestSection
	// contains filtered or unexported fields
}

func (TestSuite_builder) Build

func (b0 TestSuite_builder) Build() *TestSuite

type TypedResult

type TypedResult struct {

	// A normal value, which must match the evaluation result exactly
	// via value equality semantics. This is ignored if the test is `check_only`.
	Result *expr.Value `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"`
	// The deduced type of the expression as reported by the checker.
	DeducedType *expr.Type `protobuf:"bytes,2,opt,name=deduced_type,json=deducedType,proto3" json:"deduced_type,omitempty"`
	// contains filtered or unexported fields
}

Matches a result along with deduced expression type.

func (*TypedResult) ClearDeducedType

func (x *TypedResult) ClearDeducedType()

func (*TypedResult) ClearResult

func (x *TypedResult) ClearResult()

func (*TypedResult) GetDeducedType

func (x *TypedResult) GetDeducedType() *expr.Type

func (*TypedResult) GetResult

func (x *TypedResult) GetResult() *expr.Value

func (*TypedResult) HasDeducedType

func (x *TypedResult) HasDeducedType() bool

func (*TypedResult) HasResult

func (x *TypedResult) HasResult() bool

func (*TypedResult) ProtoMessage

func (*TypedResult) ProtoMessage()

func (*TypedResult) ProtoReflect

func (x *TypedResult) ProtoReflect() protoreflect.Message

func (*TypedResult) Reset

func (x *TypedResult) Reset()

func (*TypedResult) SetDeducedType

func (x *TypedResult) SetDeducedType(v *expr.Type)

func (*TypedResult) SetResult

func (x *TypedResult) SetResult(v *expr.Value)

func (*TypedResult) String

func (x *TypedResult) String() string

type TypedResult_builder

type TypedResult_builder struct {

	// A normal value, which must match the evaluation result exactly
	// via value equality semantics. This is ignored if the test is `check_only`.
	Result *expr.Value
	// The deduced type of the expression as reported by the checker.
	DeducedType *expr.Type
	// contains filtered or unexported fields
}

func (TypedResult_builder) Build

func (b0 TypedResult_builder) Build() *TypedResult

type UnknownSetMatcher

type UnknownSetMatcher struct {

	// Success if we match any of these sets.
	Unknowns []*expr.UnknownSet `protobuf:"bytes,1,rep,name=unknowns,proto3" json:"unknowns,omitempty"`
	// contains filtered or unexported fields
}

Matches unknown results from Eval.

func (*UnknownSetMatcher) GetUnknowns

func (x *UnknownSetMatcher) GetUnknowns() []*expr.UnknownSet

func (*UnknownSetMatcher) ProtoMessage

func (*UnknownSetMatcher) ProtoMessage()

func (*UnknownSetMatcher) ProtoReflect

func (x *UnknownSetMatcher) ProtoReflect() protoreflect.Message

func (*UnknownSetMatcher) Reset

func (x *UnknownSetMatcher) Reset()

func (*UnknownSetMatcher) SetUnknowns

func (x *UnknownSetMatcher) SetUnknowns(v []*expr.UnknownSet)

func (*UnknownSetMatcher) String

func (x *UnknownSetMatcher) String() string

type UnknownSetMatcher_builder

type UnknownSetMatcher_builder struct {

	// Success if we match any of these sets.
	Unknowns []*expr.UnknownSet
	// contains filtered or unexported fields
}

func (UnknownSetMatcher_builder) Build

Source Files

  • simple.pb.go
  • suite.pb.go

Jump to

Keyboard shortcuts

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