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

Function TestEnvFromConfigErrors

cel/env_test.go:1104–1197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1102}
1103
1104func TestEnvFromConfigErrors(t *testing.T) {
1105 tests := []struct {
1106 name string
1107 conf *env.Config
1108 want error
1109 }{
1110 {
1111 name: "bad container",
1112 conf: env.NewConfig("bad container").SetContainer(".hello.world"),
1113 want: errors.New("container name must not contain"),
1114 },
1115 {
1116 name: "colliding imports",
1117 conf: env.NewConfig("colliding imports").AddImports(env.NewImport("pkg.ImportName"), env.NewImport("pkg2.ImportName")),
1118 want: errors.New("abbreviation collides"),
1119 },
1120 {
1121 name: "invalid subset",
1122 conf: env.NewConfig("invalid subset").SetStdLib(env.NewLibrarySubset().SetDisableMacros(true)),
1123 want: errors.New("invalid subset"),
1124 },
1125 {
1126 name: "invalid import",
1127 conf: env.NewConfig("invalid import").AddImports(env.NewImport("")),
1128 want: errors.New("invalid import"),
1129 },
1130 {
1131 name: "invalid context proto",
1132 conf: env.NewConfig("invalid context proto").SetContextVariable(env.NewContextVariable("invalid")),
1133 want: errors.New("invalid context proto type"),
1134 },
1135 {
1136 name: "undefined variable type",
1137 conf: env.NewConfig("undefined variable type").AddVariables(env.NewVariable("undef", env.NewTypeDesc("undefined"))),
1138 want: errors.New("invalid variable"),
1139 },
1140 {
1141 name: "undefined function type",
1142 conf: env.NewConfig("undefined function type").AddFunctions(env.NewFunction("invalid", env.NewOverload("invalid", []*env.TypeDesc{}, env.NewTypeDesc("undefined")))),
1143 want: errors.New("invalid function"),
1144 },
1145 {
1146 name: "unrecognized extension",
1147 conf: env.NewConfig("unrecognized extension").
1148 AddExtensions(env.NewExtension("unrecognized", math.MaxUint32)),
1149 want: errors.New("unrecognized extension"),
1150 },
1151 {
1152 name: "invalid validator config",
1153 conf: env.NewConfig("invalid validator config").
1154 AddValidators(env.NewValidator("cel.validator.comprehension_nesting_limit")),
1155 want: errors.New("invalid validator"),
1156 },
1157 {
1158 name: "invalid validator config type - unsupported type",
1159 conf: env.NewConfig("invalid validator config").
1160 AddValidators(env.NewValidator("cel.validator.comprehension_nesting_limit").SetConfig(map[string]any{"limit": "2"})),
1161 want: errors.New("invalid validator"),

Callers

nothing calls this directly

Calls 15

NewConfigFunction · 0.92
NewImportFunction · 0.92
NewLibrarySubsetFunction · 0.92
NewContextVariableFunction · 0.92
NewVariableFunction · 0.92
NewTypeDescFunction · 0.92
NewFunctionFunction · 0.92
NewOverloadFunction · 0.92
NewExtensionFunction · 0.92
NewValidatorFunction · 0.92
SetContainerMethod · 0.80
NewMethod · 0.80

Tested by

no test coverage detected