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

Function TestEnvToConfig

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

Source from the content-addressed store, hash-verified

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

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