Skip to content

Commit

Permalink
Assert equal vs Assert true for comparisons (#2486)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 authored Oct 4, 2024
1 parent ffe0042 commit d51ffb9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 18 deletions.
9 changes: 3 additions & 6 deletions cmd/certsuite/claim/compare/testcases/testcases_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package testcases

import (
"maps"
"reflect"
"slices"
"testing"

"github.com/redhat-best-practices-for-k8s/certsuite/cmd/certsuite/pkg/claim"
Expand Down Expand Up @@ -80,7 +77,7 @@ func TestGetTestCasesResultsMap(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
resultsMap := getTestCasesResultsMap(tc.results)
assert.True(t, maps.Equal(tc.expectedTestCasesResultsMap, resultsMap))
assert.Equal(t, tc.expectedTestCasesResultsMap, resultsMap)
})
}
}
Expand Down Expand Up @@ -139,7 +136,7 @@ func TestGetMergedTestCasesNames(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
tcMergedNamesList := getMergedTestCasesNames(tc.claim1Results, tc.claim2Results)
assert.True(t, slices.Equal(tc.expectedMergedTcNames, tcMergedNamesList))
assert.Equal(t, tc.expectedMergedTcNames, tcMergedNamesList)
})
}
}
Expand Down Expand Up @@ -304,7 +301,7 @@ func TestGetDiffReport(t *testing.T) {

// Check test case results differences
t.Logf("diffs: %+v", diffReport.TestCases)
assert.True(t, reflect.DeepEqual(tc.expectedDiffReport.TestCases, diffReport.TestCases))
assert.Equal(t, tc.expectedDiffReport.TestCases, diffReport.TestCases)

// Check count
assert.Equal(t, tc.expectedDiffReport.DifferentTestCasesResults, diffReport.DifferentTestCasesResults)
Expand Down
3 changes: 1 addition & 2 deletions cmd/certsuite/generate/catalog/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package catalog

import (
"errors"
"slices"
"sort"
"testing"

Expand Down Expand Up @@ -82,6 +81,6 @@ func TestGetSuitesFromIdentifiers(t *testing.T) {
sort.Strings(tc.expectedSuites)
results := GetSuitesFromIdentifiers(tc.testKeys)
sort.Strings(results)
assert.True(t, slices.Equal(tc.expectedSuites, results))
assert.Equal(t, tc.expectedSuites, results)
}
}
6 changes: 2 additions & 4 deletions pkg/arrayhelper/arrayhelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package arrayhelper

import (
"maps"
"slices"
"sort"
"strings"
"testing"
Expand Down Expand Up @@ -84,7 +82,7 @@ func TestArgListToMap(t *testing.T) {
}

for _, tc := range testCases {
assert.True(t, maps.Equal(tc.expectedMap, ArgListToMap(tc.argList)))
assert.Equal(t, tc.expectedMap, ArgListToMap(tc.argList))
}
}

Expand All @@ -111,6 +109,6 @@ func TestUnique(t *testing.T) {
sort.Strings(tc.expectedSlice)
results := Unique(tc.testSlice)
sort.Strings(results)
assert.True(t, slices.Equal(tc.expectedSlice, results))
assert.Equal(t, tc.expectedSlice, results)
}
}
3 changes: 1 addition & 2 deletions pkg/autodiscover/autodiscover_operators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package autodiscover

import (
"slices"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -51,6 +50,6 @@ func TestGetAllNamespaces(t *testing.T) {
clientSet := fake.NewSimpleClientset(testRuntimeObjects...)
namespaces, err := getAllNamespaces(clientSet.CoreV1())
assert.Nil(t, err)
assert.True(t, slices.Equal(tc.expectedNamespaces, namespaces))
assert.Equal(t, tc.expectedNamespaces, namespaces)
}
}
3 changes: 1 addition & 2 deletions tests/platform/operatingsystem/operatingsystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package operatingsystem

import (
"errors"
"maps"
"os"
"testing"

Expand Down Expand Up @@ -62,7 +61,7 @@ func TestGetRHCOSMappedVersionsFromFile(t *testing.T) {
} else {
result, err := GetRHCOSMappedVersions(string(file))
assert.Nil(t, err)
assert.True(t, maps.Equal(tc.expectedOutput, result))
assert.Equal(t, tc.expectedOutput, result)
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions tests/platform/sysctlconfig/sysctlconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package sysctlconfig

import (
"maps"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -59,6 +58,6 @@ func TestParseSysctlSystemOutput(t *testing.T) {
}

for _, tc := range testCases {
assert.True(t, maps.Equal(parseSysctlSystemOutput(tc.sysctlOutput), tc.expectedResult))
assert.Equal(t, parseSysctlSystemOutput(tc.sysctlOutput), tc.expectedResult)
}
}

0 comments on commit d51ffb9

Please sign in to comment.