From d148b954dda168a542e78eb4faa1798a8cd5a389 Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Fri, 10 Dec 2021 13:54:52 +0100 Subject: [PATCH] Ignore order when testing for nil values in test --- preload_associations_test.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/preload_associations_test.go b/preload_associations_test.go index 507d04e4..3d70bad9 100644 --- a/preload_associations_test.go +++ b/preload_associations_test.go @@ -158,8 +158,19 @@ func Test_New_Implementation_For_Nplus1_With_NullUUIDs_And_FK_ID(t *testing.T) { // "created_at": "0001-01-01T00:00:00Z", // "updated_at": "0001-01-01T00:00:00Z" // }, - a.NotNil(expected.Hops[0].Server, "%+v", expected.Hops[0]) - a.Nil(expected.Hops[1].Server) + var foundValid, foundEmpty int + for _, hop := range expected.Hops { + if hop.ServerID.Valid { + foundValid++ + a.NotNil(hop.Server, "%+v", hop) + } else { + foundEmpty++ + a.Nil(hop.Server, "%+v", hop) + } + } + + a.Equal(1, foundValid) + a.Equal(1, foundEmpty) }) }