From f980ca9f4ad98161c3bbcd421776dd807f8a2ee1 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Fri, 6 Sep 2024 17:07:02 -0700 Subject: [PATCH] internal/host/plugin: fix flaky test Hosts contain IP addresses in string form, whose order is not defined. --- internal/host/plugin/repository_host_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/host/plugin/repository_host_test.go b/internal/host/plugin/repository_host_test.go index 89997f68be..cc9468cd0a 100644 --- a/internal/host/plugin/repository_host_test.go +++ b/internal/host/plugin/repository_host_test.go @@ -221,6 +221,9 @@ func TestJob_UpsertHosts(t *testing.T) { cmpopts.SortSlices(func(x, y *Host) bool { return x.GetPublicId() < y.GetPublicId() }), + cmpopts.SortSlices(func(x, y string) bool { + return x < y + }), ), ) @@ -242,6 +245,9 @@ func TestJob_UpsertHosts(t *testing.T) { cmpopts.SortSlices(func(x, y *Host) bool { return x.GetPublicId() < y.GetPublicId() }), + cmpopts.SortSlices(func(x, y string) bool { + return x < y + }), ), ) plg := plg @@ -274,6 +280,9 @@ func TestJob_UpsertHosts(t *testing.T) { got, cmpopts.IgnoreUnexported(Host{}, store.Host{}), cmpopts.IgnoreTypes(×tamp.Timestamp{}), + cmpopts.SortSlices(func(x, y string) bool { + return x < y + }), ), ) assert.Empty(