From 7ac97273855e5e68d9e4b10e96d5466201fb8871 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Sat, 28 Nov 2015 14:56:30 +0100 Subject: PLT-1035: Remove last data point in graphs on #statistics page --- utils/time_test.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 utils/time_test.go (limited to 'utils/time_test.go') diff --git a/utils/time_test.go b/utils/time_test.go new file mode 100644 index 000000000..7d65046bf --- /dev/null +++ b/utils/time_test.go @@ -0,0 +1,50 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package utils + +import ( + "testing" + "time" +) + +var format = "2006-01-02 15:04:05.000000000" + +func TestMillisFromTime(t *testing.T) { + input, _ := time.Parse(format, "2015-01-01 12:34:00.000000000") + actual := MillisFromTime(input) + expected := int64(1420115640000) + + if actual != expected { + t.Fatalf("TestMillisFromTime failed, %v=%v", expected, actual) + } +} + +func TestYesterday(t *testing.T) { + actual := Yesterday() + expected := time.Now().AddDate(0, 0, -1) + + if actual.Year() != expected.Year() || actual.Day() != expected.Day() || actual.Month() != expected.Month() { + t.Fatalf("TestYesterday failed, %v=%v", expected, actual) + } +} + +func TestStartOfDay(t *testing.T) { + input, _ := time.Parse(format, "2015-01-01 12:34:00.000000000") + actual := StartOfDay(input) + expected, _ := time.Parse(format, "2015-01-01 00:00:00.000000000") + + if actual != expected { + t.Fatalf("TestStartOfDay failed, %v=%v", expected, actual) + } +} + +func TestEndOfDay(t *testing.T) { + input, _ := time.Parse(format, "2015-01-01 12:34:00.000000000") + actual := EndOfDay(input) + expected, _ := time.Parse(format, "2015-01-01 23:59:59.999999999") + + if actual != expected { + t.Fatalf("TestEndOfDay failed, %v=%v", expected, actual) + } +} -- cgit v1.2.3-1-g7c22