diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2018-10-05 22:25:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-05 22:25:34 +0800 |
commit | 69e10651c97c7d7b30aa69a0155c8d3293e2b9bd (patch) | |
tree | 5f430cdb9c9226d622ad393f6fdbf8c7d30ae9fe /model/utils_test.go | |
parent | cba33137d25336cd5a5bcfd1d68695b584714f56 (diff) | |
download | chat-69e10651c97c7d7b30aa69a0155c8d3293e2b9bd.tar.gz chat-69e10651c97c7d7b30aa69a0155c8d3293e2b9bd.tar.bz2 chat-69e10651c97c7d7b30aa69a0155c8d3293e2b9bd.zip |
[MM-12484] Fix return search posts on date filters (#9568)
* fix return search posts on date filters
* add name to test cases
Diffstat (limited to 'model/utils_test.go')
-rw-r--r-- | model/utils_test.go | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/model/utils_test.go b/model/utils_test.go index 1db91d6e6..ec4bb83d1 100644 --- a/model/utils_test.go +++ b/model/utils_test.go @@ -44,25 +44,26 @@ func TestGetMillisForTime(t *testing.T) { } } -func TestParseDateFilterToTimeISO8601(t *testing.T) { - testString := "2016-08-01" - compareTime := time.Date(2016, time.August, 1, 0, 0, 0, 0, time.UTC) - - result := ParseDateFilterToTime(testString) - - if result != compareTime { - t.Fatalf(fmt.Sprintf("parsed date doesn't match the expected result: parsed result %v and expected time %v", result, compareTime)) - } -} - -func TestParseDateFilterToTimeNeedZeroPadding(t *testing.T) { - testString := "2016-8-1" - compareTime := time.Date(2016, time.August, 1, 0, 0, 0, 0, time.UTC) - - result := ParseDateFilterToTime(testString) - - if result != compareTime { - t.Fatalf(fmt.Sprintf("parsed date doesn't match the expected result: parsed result %v and expected time %v", result, compareTime)) +func TestPadDateStringZeros(t *testing.T) { + for _, testCase := range []struct { + Name string + Input string + Expected string + }{ + { + Name: "Valid date", + Input: "2016-08-01", + Expected: "2016-08-01", + }, + { + Name: "Valid date but requires padding of zero", + Input: "2016-8-1", + Expected: "2016-08-01", + }, + } { + t.Run(testCase.Name, func(t *testing.T) { + assert.Equal(t, testCase.Expected, PadDateStringZeros(testCase.Input)) + }) } } |