diff options
| author | Grant Ammons <grant@pipelinedealsco.com> | 2017-01-16 09:04:02 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-16 09:04:02 -0500 |
| commit | 955330761278748518d5cf0b0d92cd5f90cfdeae (patch) | |
| tree | 70040ff639ffc52c81740293f400f303d53d4096 | |
| parent | c3c8817de6228557ba865465e3d639a104578587 (diff) | |
| parent | b45e96087c4a1dbbb99b6f54d576c71d54ec3bbf (diff) | |
Merge pull request #20 from gammons/future-proof-tests
Fix tests by removing hard-coded year
| -rw-r--r-- | todolist/parser_test.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/todolist/parser_test.go b/todolist/parser_test.go index 37a4910..83c0602 100644 --- a/todolist/parser_test.go +++ b/todolist/parser_test.go @@ -2,6 +2,7 @@ package todolist import ( "fmt" + "strconv" "testing" "time" @@ -81,7 +82,8 @@ func TestDueSpecific(t *testing.T) { assert := assert.New(t) parser := &Parser{} todo := parser.ParseNewTodo("do this thing with @bob and @mary due jun 1") - assert.Equal("2016-06-01", todo.Due) + year := strconv.Itoa(time.Now().Year()) + assert.Equal(fmt.Sprintf("%s-06-01", year), todo.Due) } func TestMondayOnSunday(t *testing.T) { @@ -122,14 +124,16 @@ func TestTuesdayOnWednesday(t *testing.T) { func TestDueOnSpecificDate(t *testing.T) { assert := assert.New(t) parser := &Parser{} - assert.Equal("2016-05-02", parser.Due("due may 2", time.Now())) - assert.Equal("2016-06-01", parser.Due("due jun 1", time.Now())) + year := strconv.Itoa(time.Now().Year()) + assert.Equal(fmt.Sprintf("%s-05-02", year), parser.Due("due may 2", time.Now())) + assert.Equal(fmt.Sprintf("%s-06-01", year), parser.Due("due jun 1", time.Now())) } func TestDueOnSpecificDateEuropean(t *testing.T) { assert := assert.New(t) parser := &Parser{} - assert.Equal("2016-05-02", parser.Due("due 2 may", time.Now())) + year := strconv.Itoa(time.Now().Year()) + assert.Equal(fmt.Sprintf("%s-05-02", year), parser.Due("due 2 may", time.Now())) } func TestDueIntelligentlyChoosesCorrectYear(t *testing.T) { |
