fix: flaky test

This commit is contained in:
2022-09-30 22:32:56 +02:00
parent 510023284e
commit 0f58b4c280
2 changed files with 11 additions and 0 deletions
+4
View File
@@ -2,3 +2,7 @@ vendor
.gitignore .gitignore
.git .git
Dockerfile Dockerfile
coverage.txt
coverage.html
/exported
/release
+7
View File
@@ -3,6 +3,7 @@ package kube
import ( import (
"context" "context"
"fmt" "fmt"
"sort"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@@ -269,6 +270,12 @@ func TestClient_GetImages(t *testing.T) {
if !tt.wantErr(t, err, fmt.Sprintf("GetImages(%v, %v, %v)", ctx, logger, tt.args.namespaces)) { if !tt.wantErr(t, err, fmt.Sprintf("GetImages(%v, %v, %v)", ctx, logger, tt.args.namespaces)) {
return return
} }
for k, v := range got {
sort.SliceStable(v, func(i, j int) bool {
return v[i] < v[j]
})
got[k] = v
}
assert.Equalf(t, tt.want, got, "GetImages(%v, %v, %v)", ctx, logger, tt.args.namespaces) assert.Equalf(t, tt.want, got, "GetImages(%v, %v, %v)", ctx, logger, tt.args.namespaces)
logger.Check(t, tt.wantLogged) logger.Check(t, tt.wantLogged)
}) })