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

Function TestLibraries

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

Source from the content-addressed store, hash-verified

281}
282
283func TestLibraries(t *testing.T) {
284 e, err := NewEnv(OptionalTypes())
285 if err != nil {
286 t.Fatalf("NewEnv() failed: %v", err)
287 }
288 for _, expected := range []string{"cel.lib.std", "cel.lib.optional"} {
289 if !e.HasLibrary(expected) {
290 t.Errorf("Expected HasLibrary() to return true for '%s'", expected)
291 }
292 libMap := map[string]struct{}{}
293 libraries := e.Libraries()
294 for _, lib := range libraries {
295 libMap[lib] = struct{}{}
296 }
297 if len(libraries) != 2 {
298 t.Errorf("Expected HasLibrary() to contain exactly 2 libraries but got: %v", libraries)
299 }
300
301 if _, ok := libMap[expected]; !ok {
302 t.Errorf("Expected Libraries() to include '%s'", expected)
303 }
304 }
305}
306
307func TestFunctions(t *testing.T) {
308 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