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

Function TestLibraries

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

Source from the content-addressed store, hash-verified

422}
423
424func TestLibraries(t *testing.T) {
425 e, err := NewEnv(OptionalTypes())
426 if err != nil {
427 t.Fatalf("NewEnv() failed: %v", err)
428 }
429 for _, expected := range []string{"cel.lib.std", "cel.lib.optional"} {
430 if !e.HasLibrary(expected) {
431 t.Errorf("Expected HasLibrary() to return true for '%s'", expected)
432 }
433 libMap := map[string]struct{}{}
434 libraries := e.Libraries()
435 for _, lib := range libraries {
436 libMap[lib] = struct{}{}
437 }
438 if len(libraries) != 2 {
439 t.Errorf("Expected HasLibrary() to contain exactly 2 libraries but got: %v", libraries)
440 }
441
442 if _, ok := libMap[expected]; !ok {
443 t.Errorf("Expected Libraries() to include '%s'", expected)
444 }
445 }
446}
447
448func TestFunctions(t *testing.T) {
449 e, err := NewEnv(OptionalTypes())

Callers

nothing calls this directly

Calls 4

HasLibraryMethod · 0.95
LibrariesMethod · 0.95
OptionalTypesFunction · 0.85
NewEnvFunction · 0.70

Tested by

no test coverage detected