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

Function TestCustomEnv

cel/cel_test.go:292–313  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

290}
291
292func TestCustomEnv(t *testing.T) {
293 env, err := NewCustomEnv(Variable("a.b.c", BoolType))
294 if err != nil {
295 t.Fatalf("NewCustomEnv(a.b.c:bool) failed: %v", err)
296 }
297 t.Run("err", func(t *testing.T) {
298 _, iss := compileOrError(t, env, "a.b.c == true")
299 if iss == nil {
300 t.Error("got successful compile, expected error for missing operator '_==_'")
301 }
302 })
303
304 t.Run("ok", func(t *testing.T) {
305 out, err := interpret(t, env, "a.b.c", map[string]any{"a.b.c": true})
306 if err != nil {
307 t.Fatal(err)
308 }
309 if out != types.True {
310 t.Errorf("got '%v', wanted 'true'", out.Value())
311 }
312 })
313}
314
315func TestCrossTypeNumericComparisons(t *testing.T) {
316 tests := []struct {

Callers

nothing calls this directly

Calls 6

NewCustomEnvFunction · 0.85
compileOrErrorFunction · 0.85
interpretFunction · 0.85
VariableFunction · 0.70
ValueMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected