From 091390c8ab2f9ea7248eb9c38d5d80df3b0b01d7 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 12 Jan 2023 15:28:29 +0100 Subject: [PATCH] fix(tasks): read all tests --- pkg/models/task_collection_test.go | 46 ++++++------------------------ 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/pkg/models/task_collection_test.go b/pkg/models/task_collection_test.go index e5df9d240..5b9256664 100644 --- a/pkg/models/task_collection_test.go +++ b/pkg/models/task_collection_test.go @@ -445,32 +445,6 @@ func TestTaskCollection_ReadAll(t *testing.T) { Created: time.Unix(1543626724, 0).In(loc), Updated: time.Unix(1543626724, 0).In(loc), } - task25 := &Task{ - ID: 25, - Title: "task #25", - Identifier: "test16-1", - Index: 1, - CreatedByID: 6, - CreatedBy: user6, - ProjectID: 15, - RelatedTasks: map[RelationKind][]*Task{}, - BucketID: 16, - Created: time.Unix(1543626724, 0).In(loc), - Updated: time.Unix(1543626724, 0).In(loc), - } - task26 := &Task{ - ID: 26, - Title: "task #26", - Identifier: "test17-1", - Index: 1, - CreatedByID: 6, - CreatedBy: user6, - ProjectID: 15, - RelatedTasks: map[RelationKind][]*Task{}, - BucketID: 17, - Created: time.Unix(1543626724, 0).In(loc), - Updated: time.Unix(1543626724, 0).In(loc), - } task27 := &Task{ ID: 27, Title: "task #27 with reminders", @@ -665,7 +639,7 @@ func TestTaskCollection_ReadAll(t *testing.T) { }, { // For more sorting tests see task_collection_sort_test.go - name: "ReadAll Tasks sorted by done asc and id desc", + name: "sorted by done asc and id desc", fields: fields{ SortBy: []string{"done", "id"}, OrderBy: []string{"asc", "desc"}, @@ -679,8 +653,6 @@ func TestTaskCollection_ReadAll(t *testing.T) { task29, task28, task27, - task26, - task25, task24, task23, task22, @@ -792,8 +764,6 @@ func TestTaskCollection_ReadAll(t *testing.T) { task22, task23, task24, - task25, - task26, task27, task28, @@ -863,8 +833,6 @@ func TestTaskCollection_ReadAll(t *testing.T) { task22, // has nil dates task23, // has nil dates task24, // has nil dates - task25, // has nil dates - task26, // has nil dates task27, // has nil dates task28, // has nil dates task29, // has nil dates @@ -1118,8 +1086,6 @@ func TestTaskCollection_ReadAll(t *testing.T) { task22, task23, task24, - task25, - task26, task27, task28, task29, @@ -1150,8 +1116,6 @@ func TestTaskCollection_ReadAll(t *testing.T) { task29, task28, task27, - task26, - task25, task24, task23, task22, @@ -1219,7 +1183,13 @@ func TestTaskCollection_ReadAll(t *testing.T) { return } if diff, equal := messagediff.PrettyDiff(got, tt.want); !equal { - if len(got.([]*Task)) == 0 && len(tt.want) == 0 { + var is bool + var gotTasks []*Task + gotTasks, is = got.([]*Task) + if !is { + gotTasks = []*Task{} + } + if len(gotTasks) == 0 && len(tt.want) == 0 { return }