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

Function TestLibraries

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

Source from the content-addressed store, hash-verified

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