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

Function TestEnvToConfig

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

Source from the content-addressed store, hash-verified

462}
463
464func TestEnvToConfig(t *testing.T) {
465 tests := []struct {
466 name string
467 opts []EnvOption
468 want *env.Config
469 }{
470 {
471 name: "std env",
472 want: env.NewConfig("std env"),
473 },
474 {
475 name: "std env - container",
476 opts: []EnvOption{
477 Container("example.container"),
478 },
479 want: env.NewConfig("std env - container").SetContainer("example.container"),
480 },
481 {
482 name: "std env - aliases",
483 opts: []EnvOption{
484 Abbrevs("example.type.name"),
485 },
486 want: env.NewConfig("std env - aliases").AddImports(env.NewImport("example.type.name")),
487 },
488 {
489 name: "std env disabled",
490 opts: []EnvOption{
491 func(*Env) (*Env, error) {
492 return NewCustomEnv()
493 },
494 },
495 want: env.NewConfig("std env disabled").SetStdLib(
496 env.NewLibrarySubset().SetDisabled(true)),
497 },
498 {
499 name: "std env - with variable",
500 opts: []EnvOption{
501 Variable("var", IntType),
502 },
503 want: env.NewConfig("std env - with variable").AddVariables(env.NewVariable("var", env.NewTypeDesc("int"))),
504 },
505 {
506 name: "std env - with function",
507 opts: []EnvOption{Function("hello", Overload("hello_string", []*Type{StringType}, StringType))},
508 want: env.NewConfig("std env - with function").AddFunctions(
509 env.NewFunction("hello",
510 env.NewOverload("hello_string",
511 []*env.TypeDesc{env.NewTypeDesc("string")}, env.NewTypeDesc("string")),
512 )),
513 },
514 {
515 name: "optional lib",
516 opts: []EnvOption{
517 OptionalTypes(),
518 },
519 want: env.NewConfig("optional lib").AddExtensions(env.NewExtension("optional", math.MaxUint32)),
520 },
521 {

Callers

nothing calls this directly

Calls 15

ToConfigMethod · 0.95
NewConfigFunction · 0.92
NewImportFunction · 0.92
NewLibrarySubsetFunction · 0.92
NewVariableFunction · 0.92
NewTypeDescFunction · 0.92
NewFunctionFunction · 0.92
NewOverloadFunction · 0.92
NewExtensionFunction · 0.92
NewFunctionWithDocFunction · 0.92
NewMemberOverloadFunction · 0.92
NewFeatureFunction · 0.92

Tested by

no test coverage detected