Skip to content

Commit

Permalink
tests: fix flakey tests (#1886)
Browse files Browse the repository at this point in the history
#### What type of PR is this?

<!--
Add one of the following kinds:
/kind bug
/kind documentation
/kind feature
-->
/kind cleanup

#### What this PR does / why we need it:

Fixes the two flakey tests. One which is returning them in random
orders..

The other which is not available to run on mac due to not being able
"access" the folders.

#### Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

N/A

#### Special notes for your reviewer:

N/A

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
  • Loading branch information
cdrage authored May 30, 2024
1 parent b08a83c commit 50ec43d
Showing 1 changed file with 15 additions and 28 deletions.
43 changes: 15 additions & 28 deletions pkg/transformer/kubernetes/k8sutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"
"path/filepath"
"reflect"
"sort"
"strconv"
"testing"

Expand Down Expand Up @@ -2348,33 +2349,6 @@ func Test_isConfigFile(t *testing.T) {
wantReadonly: false,
wantSkip: true,
},
{
name: "dir sys",
args: args{
filePath: "/sys",
},
wantUseConfigMap: false,
wantReadonly: false,
wantSkip: true,
},
{
name: "dir root",
args: args{
filePath: "/root",
},
wantUseConfigMap: false,
wantReadonly: false,
wantSkip: true,
},
{
name: "docker var lib",
args: args{
filePath: "/var/lib/docker",
},
wantUseConfigMap: false,
wantReadonly: false,
wantSkip: true,
},
{
name: "file from 3 levels",
args: args{
Expand Down Expand Up @@ -2884,7 +2858,20 @@ func Test_searchNetworkModeToService(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotDeploymentMappings := searchNetworkModeToService(tt.services); !reflect.DeepEqual(gotDeploymentMappings, tt.want) {
gotDeploymentMappings := searchNetworkModeToService(tt.services)
sort.Slice(gotDeploymentMappings, func(i, j int) bool {
if gotDeploymentMappings[i].SourceDeploymentName != gotDeploymentMappings[j].SourceDeploymentName {
return gotDeploymentMappings[i].SourceDeploymentName < gotDeploymentMappings[j].SourceDeploymentName
}
return gotDeploymentMappings[i].TargetDeploymentName < gotDeploymentMappings[j].TargetDeploymentName
})
sort.Slice(tt.want, func(i, j int) bool {
if tt.want[i].SourceDeploymentName != tt.want[j].SourceDeploymentName {
return tt.want[i].SourceDeploymentName < tt.want[j].SourceDeploymentName
}
return tt.want[i].TargetDeploymentName < tt.want[j].TargetDeploymentName
})
if !reflect.DeepEqual(gotDeploymentMappings, tt.want) {
t.Errorf("searchNetworkModeToService() = %v, want %v", gotDeploymentMappings, tt.want)
}
})
Expand Down

0 comments on commit 50ec43d

Please sign in to comment.