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

Function TestCustomEnv

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

Source from the content-addressed store, hash-verified

394}
395
396func TestCustomEnv(t *testing.T) {
397 env, err := NewCustomEnv(Variable("a.b.c", BoolType))
398 if err != nil {
399 t.Fatalf("NewCustomEnv(a.b.c:bool) failed: %v", err)
400 }
401 t.Run("err", func(t *testing.T) {
402 _, iss := compileOrError(t, env, "a.b.c == true")
403 if iss == nil {
404 t.Error("got successful compile, expected error for missing operator '_==_'")
405 }
406 })
407
408 t.Run("ok", func(t *testing.T) {
409 out, err := interpret(t, env, "a.b.c", map[string]any{"a.b.c": true})
410 if err != nil {
411 t.Fatal(err)
412 }
413 if out != types.True {
414 t.Errorf("got '%v', wanted 'true'", out.Value())
415 }
416 })
417}
418
419func TestCrossTypeNumericComparisons(t *testing.T) {
420 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