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

Function TestDefaultUTCTimeZoneExtension

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

Source from the content-addressed store, hash-verified

2632}
2633
2634func TestDefaultUTCTimeZoneExtension(t *testing.T) {
2635 env := testEnv(t,
2636 Variable("x", TimestampType),
2637 Variable("y", DurationType),
2638 )
2639 env, err := env.Extend()
2640 if err != nil {
2641 t.Fatalf("env.Extend() failed: %v", err)
2642 }
2643 out, err := interpret(t, env, `
2644 x.getFullYear() == 1970
2645 && y.getHours() == 2
2646 && y.getMinutes() == 120
2647 && y.getSeconds() == 7235
2648 && y.getMilliseconds() == 7235000`,
2649 map[string]any{
2650 "x": time.Unix(7506, 1000000).Local(),
2651 "y": time.Duration(7235) * time.Second,
2652 },
2653 )
2654 if err != nil {
2655 t.Fatalf("prg.Eval() failed: %v", err)
2656 }
2657 if out != types.True {
2658 t.Errorf("Eval() got %v, wanted true", out.Value())
2659 }
2660}
2661
2662func TestDefaultUTCTimeZoneError(t *testing.T) {
2663 env := testEnv(t, Variable("x", TimestampType))

Callers

nothing calls this directly

Calls 5

interpretFunction · 0.85
testEnvFunction · 0.70
VariableFunction · 0.70
ValueMethod · 0.65
ExtendMethod · 0.45

Tested by

no test coverage detected