Debian Codegraph @

v2/sarif/invocation_test.go

raw
1 package sarif
2
3 import (
4 "testing"
5 "time"
6
7 "github.com/stretchr/testify/assert"
8 "github.com/stretchr/testify/require"
9 )
10
11 func Test_invocation_with_time_utc(t *testing.T) {
12 success := true
13 i := (&Invocation{ExecutionSuccessful: &success}).
14 WithStartTimeUTC(mustParseTime(t, "2020-12-31T23:59:59+01:00")).
15 WithEndTimeUTC(mustParseTime(t, "2021-01-01T00:00:00+01:00"))
16
17 assert.Equal(t, `{"endTimeUtc":"2020-12-31T23:00:00Z","executionSuccessful":true,"startTimeUtc":"2020-12-31T22:59:59Z"}`, getJsonString(i))
18 }
19
20 func mustParseTime(t *testing.T, value string) time.Time {
21 ts, err := time.Parse(time.RFC3339, value)
22 require.NoError(t, err)
23 return ts
24 }