From 0905a863f50d9631e6c44488b952622e75d79785 Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Sun, 1 May 2016 15:07:45 -0400 Subject: Implement delete logic --- todolist/file_store_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'todolist/file_store_test.go') diff --git a/todolist/file_store_test.go b/todolist/file_store_test.go index 3e10491..d71c119 100644 --- a/todolist/file_store_test.go +++ b/todolist/file_store_test.go @@ -25,3 +25,22 @@ func TestNextId(t *testing.T) { store.Load() assert.Equal(3, store.NextId()) } + +func TestIndexOf(t *testing.T) { + assert := assert.New(t) + todo := &Todo{Subject: "Grant"} + store := &FileStore{FileLocation: "todos.json"} + store.Load() + + assert.Equal(-1, store.IndexOf(todo)) + assert.Equal(0, store.IndexOf(&store.Data[0])) +} + +func TestDelete(t *testing.T) { + assert := assert.New(t) + store := &FileStore{FileLocation: "todos.json"} + store.Load() + assert.Equal(2, len(store.Data)) + store.Delete(1) + assert.Equal(1, len(store.Data)) +} -- cgit v1.3