diff options
| author | Grant Ammons <gammons@gmail.com> | 2017-06-19 12:58:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-19 12:58:27 -0400 |
| commit | dafb74428d8a16b28533aa25f83f25ea255c18a3 (patch) | |
| tree | b5df1531dec03b2a2beb3a1ea05b42938684b937 /todolist/parser_test.go | |
| parent | 4a91b284cc1840ad4dc4e60e831c8c6e3de283de (diff) | |
| parent | 0d815737ccb61a6664a9943516518decdddf0bb2 (diff) | |
Merge pull request #68 from gammons/code-cleanup
Fix parsing a todo with europe date format
Diffstat (limited to 'todolist/parser_test.go')
| -rw-r--r-- | todolist/parser_test.go | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/todolist/parser_test.go b/todolist/parser_test.go index f5cc185..476edaa 100644 --- a/todolist/parser_test.go +++ b/todolist/parser_test.go @@ -75,27 +75,27 @@ func TestParseContexts(t *testing.T) { } func TestDueToday(t *testing.T) { + assert := assert.New(t) parser := &Parser{} + expectedDate := bod(time.Now()).Format("2006-01-02") + todo := parser.ParseNewTodo("do this thing with @bob and @mary due today") - if todo.Due != bod(time.Now()).Format("2006-01-02") { - fmt.Println("Date is different", todo.Due, time.Now()) - } + assert.Equal(expectedDate, todo.Due) + todo = parser.ParseNewTodo("do this thing with @bob and @mary due tod") - if todo.Due != bod(time.Now()).Format("2006-01-02") { - fmt.Println("Date is different", todo.Due, time.Now()) - } + assert.Equal(expectedDate, todo.Due) } func TestDueTomorrow(t *testing.T) { + assert := assert.New(t) parser := &Parser{} + expectedDate := bod(time.Now()).AddDate(0, 0, 1).Format("2006-01-02") + todo := parser.ParseNewTodo("do this thing with @bob and @mary due tomorrow") - if todo.Due != bod(time.Now()).AddDate(0, 0, 1).Format("2006-01-02") { - fmt.Println("Date is different", todo.Due, time.Now()) - } + assert.Equal(expectedDate, todo.Due) + todo = parser.ParseNewTodo("do this thing with @bob and @mary due tom") - if todo.Due != bod(time.Now()).AddDate(0, 0, 1).Format("2006-01-02") { - fmt.Println("Date is different", todo.Due, time.Now()) - } + assert.Equal(expectedDate, todo.Due) } func TestDueSpecific(t *testing.T) { @@ -106,6 +106,14 @@ func TestDueSpecific(t *testing.T) { assert.Equal(fmt.Sprintf("%s-06-01", year), todo.Due) } +func TestDueSpecificEuropeanDate(t *testing.T) { + assert := assert.New(t) + parser := &Parser{} + todo := parser.ParseNewTodo("do this thing with @bob and @mary due 1 jun") + year := strconv.Itoa(time.Now().Year()) + assert.Equal(fmt.Sprintf("%s-06-01", year), todo.Due) +} + func TestMondayOnSunday(t *testing.T) { assert := assert.New(t) parser := &Parser{} @@ -149,6 +157,14 @@ func TestDueOnSpecificDate(t *testing.T) { assert.Equal(fmt.Sprintf("%s-06-01", year), parser.Due("due jun 1", time.Now())) } +func TestDueOnSpecificDateEuropeFormat(t *testing.T) { + assert := assert.New(t) + parser := &Parser{} + year := strconv.Itoa(time.Now().Year()) + assert.Equal(fmt.Sprintf("%s-05-02", year), parser.Due("due 2 may", time.Now())) + assert.Equal(fmt.Sprintf("%s-06-01", year), parser.Due("due 1 jun", time.Now())) +} + func TestDueOnSpecificDateEuropean(t *testing.T) { assert := assert.New(t) parser := &Parser{} |
