From b45e96087c4a1dbbb99b6f54d576c71d54ec3bbf Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Mon, 16 Jan 2017 08:50:14 -0500 Subject: Fix tests by removing hard-coded year --- todolist/parser_test.go | 12 ++++++++---- 1 file 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) { -- cgit v1.3