Skip to content

Commit 261ef7d

Browse files
committed
fix map access in unit tests
1 parent 2f08b28 commit 261ef7d

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

internal/fwserver/server_getmetadata_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,10 @@ func TestServerGetMetadata(t *testing.T) {
10241024
testCase.server.GetMetadata(context.Background(), testCase.request, response)
10251025

10261026
// Prevent false positives with random map access in testing
1027+
sort.Slice(response.Actions, func(i int, j int) bool {
1028+
return response.Actions[i].TypeName < response.Actions[j].TypeName
1029+
})
1030+
10271031
sort.Slice(response.DataSources, func(i int, j int) bool {
10281032
return response.DataSources[i].TypeName < response.DataSources[j].TypeName
10291033
})

internal/proto5server/server_getmetadata_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ func TestServerGetMetadata(t *testing.T) {
349349
}
350350

351351
// Prevent false positives with random map access in testing
352+
sort.Slice(got.Actions, func(i int, j int) bool {
353+
return got.Actions[i].TypeName < got.Actions[j].TypeName
354+
})
355+
352356
sort.Slice(got.DataSources, func(i int, j int) bool {
353357
return got.DataSources[i].TypeName < got.DataSources[j].TypeName
354358
})

internal/proto6server/server_getmetadata_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ func TestServerGetMetadata(t *testing.T) {
349349
}
350350

351351
// Prevent false positives with random map access in testing
352+
sort.Slice(got.Actions, func(i int, j int) bool {
353+
return got.Actions[i].TypeName < got.Actions[j].TypeName
354+
})
355+
352356
sort.Slice(got.DataSources, func(i int, j int) bool {
353357
return got.DataSources[i].TypeName < got.DataSources[j].TypeName
354358
})

0 commit comments

Comments
 (0)