From 45125bd02d85cd550186722dd15439781149b127 Mon Sep 17 00:00:00 2001 From: Erik Winter Date: Mon, 2 Dec 2024 08:16:06 +0100 Subject: [PATCH] fix test --- sync/service/memory_test.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/sync/service/memory_test.go b/sync/service/memory_test.go index 9d7c134..c8a2ed3 100644 --- a/sync/service/memory_test.go +++ b/sync/service/memory_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" "go-mod.ewintr.nl/planner/item" ) @@ -50,14 +51,10 @@ func TestMemoryUpdate(t *testing.T) { if actErr != nil { t.Errorf("exp nil, got %v", actErr) } - if len(actItems) != 2 { - t.Errorf("exp 2, gor %d", len(actItems)) - } - if actItems[0].ID != t1.ID { - t.Errorf("exp %v, got %v", actItems[0].ID, t1.ID) - } - if actItems[1].ID != t2.ID { - t.Errorf("exp %v, got %v", actItems[1].ID, t2.ID) + if diff := cmp.Diff([]item.Item{t1, t2}, actItems, cmpopts.SortSlices(func(i, j item.Item) bool { + return i.ID < j.ID + })); diff != "" { + t.Errorf("(exp +, got -)\n%s", diff) } actItems, actErr = mem.Updated([]item.Kind{}, before)