MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestVariableAsCELVariable

Function TestVariableAsCELVariable

common/env/env_test.go:609–775  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

607}
608
609func TestVariableAsCELVariable(t *testing.T) {
610 tests := []struct {
611 name string
612 v *Variable
613 want any
614 }{
615 {
616 name: "nil-safety check",
617 v: nil,
618 want: errors.New("invalid variable: nil"),
619 },
620 {
621 name: "no variable name",
622 v: &Variable{},
623 want: errors.New("invalid variable"),
624 },
625 {
626 name: "no type",
627 v: &Variable{
628 Name: "hello",
629 },
630 want: errors.New("invalid type: nil"),
631 },
632 {
633 name: "bad type",
634 v: &Variable{
635 Name: "hello",
636 TypeDesc: &TypeDesc{},
637 },
638 want: errors.New("missing type name"),
639 },
640 {
641 name: "undefined type",
642 v: &Variable{
643 Name: "hello",
644 TypeDesc: &TypeDesc{TypeName: "undefined"},
645 },
646 want: errors.New("undefined type name"),
647 },
648 {
649 name: "simple type",
650 v: &Variable{
651 Name: "t",
652 TypeDesc: &TypeDesc{TypeName: "type"},
653 },
654 want: decls.NewVariable("t", types.TypeType),
655 },
656 {
657 name: "type with param",
658 v: &Variable{
659 Name: "t",
660 TypeDesc: &TypeDesc{TypeName: "type", Params: []*TypeDesc{NewTypeParam("T")}},
661 },
662 want: decls.NewVariable("t", types.NewTypeTypeWithParam(types.NewTypeParamType("T"))),
663 },
664 {
665 name: "type with too many params",
666 v: &Variable{

Callers

nothing calls this directly

Calls 15

NewVariableFunction · 0.92
NewTypeTypeWithParamFunction · 0.92
NewTypeParamTypeFunction · 0.92
NewListTypeFunction · 0.92
NewMapTypeFunction · 0.92
NewOptionalTypeFunction · 0.92
NewOpaqueTypeFunction · 0.92
NewNullableTypeFunction · 0.92
NewProtoRegistryFunction · 0.92
NewTypeParamFunction · 0.85
NewTypeDescFunction · 0.85
NewMethod · 0.80

Tested by

no test coverage detected