From c50de79c4828dbb4f9b5c23bf9e00ea4dea38a01 Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Mon, 12 Jun 2017 08:13:15 -0400 Subject: Fix #64, parsing a todo with europe date format * the `hasDue` function was not running, and therefore it was not parsing the due date. * Also added the beginnings of a more holistic test approach, using `app_test.go`. --- todolist/app_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 todolist/app_test.go (limited to 'todolist/app_test.go') diff --git a/todolist/app_test.go b/todolist/app_test.go new file mode 100644 index 0000000..f35a7bc --- /dev/null +++ b/todolist/app_test.go @@ -0,0 +1,45 @@ +package todolist + +import ( + "fmt" + "strconv" + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestAddTodo(t *testing.T) { + assert := assert.New(t) + app := &App{TodoList: &TodoList{}, TodoStore: &MemoryStore{}} + year := strconv.Itoa(time.Now().Year()) + + app.AddTodo("a do some stuff due may 23") + + todo := app.TodoList.FindById(1) + assert.Equal("do some stuff", todo.Subject) + assert.Equal(fmt.Sprintf("%s-05-23", year), todo.Due) + assert.Equal(false, todo.Completed) + assert.Equal(false, todo.Archived) + assert.Equal(false, todo.IsPriority) + assert.Equal("", todo.CompletedDate) + assert.Equal([]string{}, todo.Projects) + assert.Equal([]string{}, todo.Contexts) +} + +func TestAddTodoWithEuropeanDates(t *testing.T) { + assert := assert.New(t) + app := &App{TodoList: &TodoList{}, TodoStore: &MemoryStore{}} + + app.AddTodo("a do some stuff due 23 may") + + todo := app.TodoList.FindById(1) + assert.Equal("do some stuff", todo.Subject) + assert.Equal("2017-05-23", todo.Due) + assert.Equal(false, todo.Completed) + assert.Equal(false, todo.Archived) + assert.Equal(false, todo.IsPriority) + assert.Equal("", todo.CompletedDate) + assert.Equal([]string{}, todo.Projects) + assert.Equal([]string{}, todo.Contexts) +} -- cgit v1.3