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

Function TestCustomEnv

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

Source from the content-addressed store, hash-verified

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