Skip to content

Commit

Permalink
Add tests for Seconds/MillisecondsTimeValue
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerBrock committed Aug 1, 2017
1 parent e5c0400 commit a5aa894
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions aws/convert_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,36 @@ func TestTimeMap(t *testing.T) {
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
}
}

type TimeValueTestCase struct {
in int64
secs time.Time
millis time.Time
}

var testCasesTimeValue = []TimeValueTestCase{
{
in: int64(1501558289000),
secs: time.Unix(1501558289, 0),
millis: time.Unix(1501558289, 0),
},
{
in: int64(1501558289001),
secs: time.Unix(1501558289, 0),
millis: time.Unix(1501558289, 1*1000000),
},
}

func TestSecondsTimeValue(t *testing.T) {
for idx, testCase := range testCasesTimeValue {
out := SecondsTimeValue(&testCase.in)
assert.Equal(t, testCase.secs, out, "Unexpected value for time value at %d", idx)
}
}

func TestMillisecondsTimeValue(t *testing.T) {
for idx, testCase := range testCasesTimeValue {
out := MillisecondsTimeValue(&testCase.in)
assert.Equal(t, testCase.millis, out, "Unexpected value for time value at %d", idx)
}
}

0 comments on commit a5aa894

Please sign in to comment.