From 3175996e2927f5836288f234e7bcab5cbe536937 Mon Sep 17 00:00:00 2001 From: Todd Knight Date: Fri, 11 Jun 2021 11:43:36 -0700 Subject: [PATCH] Have account_claim_maps be deterministically ordered in test comparisons. (#1318) --- .../authmethods/authmethod_service_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/servers/controller/handlers/authmethods/authmethod_service_test.go b/internal/servers/controller/handlers/authmethods/authmethod_service_test.go index 5ea556f41..c94066bd2 100644 --- a/internal/servers/controller/handlers/authmethods/authmethod_service_test.go +++ b/internal/servers/controller/handlers/authmethods/authmethod_service_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "regexp" + "sort" "strings" "testing" @@ -997,6 +998,19 @@ func TestCreate(t *testing.T) { delete(got.Item.Attributes.Fields, "callback_url") delete(tc.res.Item.Attributes.Fields, "callback_url") } + if v, ok := got.Item.Attributes.Fields["account_claim_maps"]; ok { + lv := v.GetListValue().GetValues() + sort.Slice(lv, func(i, j int) bool { + return lv[i].GetStringValue() < lv[j].GetStringValue() + }) + } + if v, ok := tc.res.Item.Attributes.Fields["account_claim_maps"]; ok { + lv := v.GetListValue().GetValues() + sort.Slice(lv, func(i, j int) bool { + return lv[i].GetStringValue() < lv[j].GetStringValue() + }) + } + } assert.Empty(cmp.Diff(got, tc.res, protocmp.Transform(), protocmp.SortRepeatedFields(got)), "CreateAuthMethod(%q) got response %q, wanted %q", tc.req, got, tc.res) })