From 458b8831b08b6907e7fb72af8621e14ad2917cbb Mon Sep 17 00:00:00 2001 From: Raul Iglesias Date: Sun, 29 Dec 2019 19:39:14 -0500 Subject: [PATCH] [test] refs #279 - Add test for ParseDate --- src/util/datetime_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/util/datetime_test.go diff --git a/src/util/datetime_test.go b/src/util/datetime_test.go new file mode 100644 index 00000000..f0133582 --- /dev/null +++ b/src/util/datetime_test.go @@ -0,0 +1,24 @@ +package util + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestParseDate(t *testing.T) { + some_date := int64(1577665665) + datetime := time.Unix(some_date, 0) + + y, m, d := datetime.Date() + h, min, s := datetime.Hour(), datetime.Minute(), datetime.Second() + + ny, nm, nd, nh, nmin, ns := ParseDate(some_date) + require.Equal(t, y, ny) + require.Equal(t, int(m), nm) + require.Equal(t, d, nd) + require.Equal(t, h, nh) + require.Equal(t, min, nmin) + require.Equal(t, s, ns) +}