From 291871d85bf788190de6f573106587c9dd07c1b1 Mon Sep 17 00:00:00 2001 From: SammyOina Date: Wed, 12 Jul 2023 10:25:05 +0300 Subject: [PATCH] sort slices before comparison Signed-off-by: SammyOina --- bootstrap/service_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bootstrap/service_test.go b/bootstrap/service_test.go index f37d83864d3..92be4e8c53a 100644 --- a/bootstrap/service_test.go +++ b/bootstrap/service_test.go @@ -12,6 +12,7 @@ import ( "fmt" "io" "net/http/httptest" + "sort" "strconv" "testing" @@ -330,6 +331,12 @@ func TestUpdateCert(t *testing.T) { for _, tc := range cases { cfg, err := svc.UpdateCert(context.Background(), tc.token, tc.thingKey, tc.clientCert, tc.clientKey, tc.caCert) assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err)) + sort.Slice(cfg.MFChannels, func(i, j int) bool { + return cfg.MFChannels[i].ID < cfg.MFChannels[j].ID + }) + sort.Slice(tc.expectedConfig.MFChannels, func(i, j int) bool { + return tc.expectedConfig.MFChannels[i].ID < tc.expectedConfig.MFChannels[j].ID + }) assert.Equal(t, tc.expectedConfig, cfg, fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.expectedConfig, cfg)) } }