Skip to content

Commit

Permalink
sort slices before comparison
Browse files Browse the repository at this point in the history
Signed-off-by: SammyOina <[email protected]>
  • Loading branch information
SammyOina committed Jul 13, 2023
1 parent ce81233 commit 291871d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bootstrap/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"fmt"
"io"
"net/http/httptest"
"sort"
"strconv"
"testing"

Expand Down Expand Up @@ -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))
}
}
Expand Down

0 comments on commit 291871d

Please sign in to comment.