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

Function TestEnvToConfig

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

Source from the content-addressed store, hash-verified

321}
322
323func TestEnvToConfig(t *testing.T) {
324 tests := []struct {
325 name string
326 opts []EnvOption
327 want *env.Config
328 }{
329 {
330 name: "std env",
331 want: env.NewConfig("std env"),
332 },
333 {
334 name: "std env - container",
335 opts: []EnvOption{
336 Container("example.container"),
337 },
338 want: env.NewConfig("std env - container").SetContainer("example.container"),
339 },
340 {
341 name: "std env - aliases",
342 opts: []EnvOption{
343 Abbrevs("example.type.name"),
344 },
345 want: env.NewConfig("std env - aliases").AddImports(env.NewImport("example.type.name")),
346 },
347 {
348 name: "std env disabled",
349 opts: []EnvOption{
350 func(*Env) (*Env, error) {
351 return NewCustomEnv()
352 },
353 },
354 want: env.NewConfig("std env disabled").SetStdLib(
355 env.NewLibrarySubset().SetDisabled(true)),
356 },
357 {
358 name: "std env - with variable",
359 opts: []EnvOption{
360 Variable("var", IntType),
361 },
362 want: env.NewConfig("std env - with variable").AddVariables(env.NewVariable("var", env.NewTypeDesc("int"))),
363 },
364 {
365 name: "std env - with function",
366 opts: []EnvOption{Function("hello", Overload("hello_string", []*Type{StringType}, StringType))},
367 want: env.NewConfig("std env - with function").AddFunctions(
368 env.NewFunction("hello",
369 env.NewOverload("hello_string",
370 []*env.TypeDesc{env.NewTypeDesc("string")}, env.NewTypeDesc("string")),
371 )),
372 },
373 {
374 name: "optional lib",
375 opts: []EnvOption{
376 OptionalTypes(),
377 },
378 want: env.NewConfig("optional lib").AddExtensions(env.NewExtension("optional", math.MaxUint32)),
379 },
380 {

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