MCPcopy
hub / github.com/google/mangle / TestTimeNow

Function TestTimeNow

functional/functional_test.go:1053–1067  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1051}
1052
1053func TestTimeNow(t *testing.T) {
1054 expr := ast.ApplyFn{symbols.TimeNow, nil}
1055 got, err := EvalApplyFn(expr, ast.ConstSubstMap{})
1056 if err != nil {
1057 t.Fatalf("EvalApplyFn(%v) failed with %v", expr, err)
1058 }
1059 if got.Type != ast.TimeType {
1060 t.Errorf("EvalApplyFn(%v) returned type %v, want TimeType", expr, got.Type)
1061 }
1062 // Check that the time is reasonable (within last minute)
1063 nanos, _ := got.TimeValue()
1064 if nanos <= 0 {
1065 t.Errorf("fn:time:now returned non-positive time: %d", nanos)
1066 }
1067}
1068
1069func TestTimeAdd(t *testing.T) {
1070 // 2024-01-15 10:30:00 UTC + 1 hour = 2024-01-15 11:30:00 UTC

Callers

nothing calls this directly

Calls 2

EvalApplyFnFunction · 0.85
TimeValueMethod · 0.80

Tested by

no test coverage detected