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

Function TestEnvFromConfigErrors

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

Source from the content-addressed store, hash-verified

959}
960
961func TestEnvFromConfigErrors(t *testing.T) {
962 tests := []struct {
963 name string
964 conf *env.Config
965 want error
966 }{
967 {
968 name: "bad container",
969 conf: env.NewConfig("bad container").SetContainer(".hello.world"),
970 want: errors.New("container name must not contain"),
971 },
972 {
973 name: "colliding imports",
974 conf: env.NewConfig("colliding imports").AddImports(env.NewImport("pkg.ImportName"), env.NewImport("pkg2.ImportName")),
975 want: errors.New("abbreviation collides"),
976 },
977 {
978 name: "invalid subset",
979 conf: env.NewConfig("invalid subset").SetStdLib(env.NewLibrarySubset().SetDisableMacros(true)),
980 want: errors.New("invalid subset"),
981 },
982 {
983 name: "invalid import",
984 conf: env.NewConfig("invalid import").AddImports(env.NewImport("")),
985 want: errors.New("invalid import"),
986 },
987 {
988 name: "invalid context proto",
989 conf: env.NewConfig("invalid context proto").SetContextVariable(env.NewContextVariable("invalid")),
990 want: errors.New("invalid context proto type"),
991 },
992 {
993 name: "undefined variable type",
994 conf: env.NewConfig("undefined variable type").AddVariables(env.NewVariable("undef", env.NewTypeDesc("undefined"))),
995 want: errors.New("invalid variable"),
996 },
997 {
998 name: "undefined function type",
999 conf: env.NewConfig("undefined function type").AddFunctions(env.NewFunction("invalid", env.NewOverload("invalid", []*env.TypeDesc{}, env.NewTypeDesc("undefined")))),
1000 want: errors.New("invalid function"),
1001 },
1002 {
1003 name: "unrecognized extension",
1004 conf: env.NewConfig("unrecognized extension").
1005 AddExtensions(env.NewExtension("unrecognized", math.MaxUint32)),
1006 want: errors.New("unrecognized extension"),
1007 },
1008 {
1009 name: "invalid validator config",
1010 conf: env.NewConfig("invalid validator config").
1011 AddValidators(env.NewValidator("cel.validator.comprehension_nesting_limit")),
1012 want: errors.New("invalid validator"),
1013 },
1014 {
1015 name: "invalid validator config type - unsupported type",
1016 conf: env.NewConfig("invalid validator config").
1017 AddValidators(env.NewValidator("cel.validator.comprehension_nesting_limit").SetConfig(map[string]any{"limit": "2"})),
1018 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