From a5aa8942702563829ff79aee7cce2ce461b93f70 Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Mon, 31 Jul 2017 21:55:58 -0700 Subject: [PATCH] Add tests for Seconds/MillisecondsTimeValue --- aws/convert_types_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/aws/convert_types_test.go b/aws/convert_types_test.go index df7a3e5d2de..0f3069d3ccb 100644 --- a/aws/convert_types_test.go +++ b/aws/convert_types_test.go @@ -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) + } +}