Skip to content

Commit

Permalink
Merge pull request #188 from digitalocean/deflake-test-for-multiple-tags
Browse files Browse the repository at this point in the history
loadbalancers: deflake test for multiple tags.
  • Loading branch information
timoreimann authored Feb 26, 2019
2 parents a2cfc1c + 3c5b4cf commit 6a7d8be
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions cloud-controller-manager/do/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"reflect"
"sort"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -216,10 +217,20 @@ func TestTagsSync(t *testing.T) {
t.Errorf("error message %q does not contain %q", err.Error(), test.errMsg)
}

if test.tagRequests != nil && !reflect.DeepEqual(test.tagRequests, fakeTagsService.tagRequests) {
want, _ := json.Marshal(test.tagRequests)
got, _ := json.Marshal(fakeTagsService.tagRequests)
t.Errorf("unexpected tagRequests %s != %s", want, got)
if test.tagRequests != nil {
// We need to sort request resources for reliable test
// assertions as informer's List() ordering is indeterministic.
for _, tagReq := range fakeTagsService.tagRequests {
sort.SliceStable(tagReq.Resources, func(i, j int) bool {
return tagReq.Resources[i].ID < tagReq.Resources[j].ID
})
}

if !reflect.DeepEqual(test.tagRequests, fakeTagsService.tagRequests) {
want, _ := json.Marshal(test.tagRequests)
got, _ := json.Marshal(fakeTagsService.tagRequests)
t.Errorf("want tagRequests %s, got %s", want, got)
}
}
})
}
Expand Down

0 comments on commit 6a7d8be

Please sign in to comment.