Skip to content

Commit 572b261

Browse files
committed
Improved tests
Signed-off-by: Marco Pracucci <[email protected]>
1 parent 36de1a6 commit 572b261

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/util/time_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ func TestDurationWithJitter_ZeroInputDuration(t *testing.T) {
4040
}
4141

4242
func TestParseTime(t *testing.T) {
43-
ts, err := time.Parse(time.RFC3339Nano, "2015-06-03T13:21:58.555Z")
44-
require.NoError(t, err)
45-
4643
var tests = []struct {
4744
input string
4845
fail bool
@@ -65,10 +62,14 @@ func TestParseTime(t *testing.T) {
6562
result: time.Unix(123, 123000000),
6663
}, {
6764
input: "2015-06-03T13:21:58.555Z",
68-
result: ts,
65+
result: time.Unix(1433337718, 555*time.Millisecond.Nanoseconds()),
6966
}, {
7067
input: "2015-06-03T14:21:58.555+01:00",
71-
result: ts,
68+
result: time.Unix(1433337718, 555*time.Millisecond.Nanoseconds()),
69+
}, {
70+
// Test nanosecond rounding.
71+
input: "2015-06-03T13:21:58.56789Z",
72+
result: time.Unix(1433337718, 567*1e6),
7273
}, {
7374
// Test float rounding.
7475
input: "1543578564.705",

0 commit comments

Comments
 (0)