Skip to content

Commit 93f82d2

Browse files
authored
Merge pull request kubernetes#127689 from mmorel-35/testifylint/[email protected]/client-go
fix: enable expected-actual rule from testifylint in module `k8s.io/client-go`
2 parents f397615 + 8286a69 commit 93f82d2

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

staging/src/k8s.io/client-go/discovery/cached/disk/cached_discovery_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,35 @@ func TestCachedDiscoveryClient_Fresh(t *testing.T) {
5757

5858
cdc.ServerGroups()
5959
assert.True(cdc.Fresh(), "should be fresh after groups call without cache")
60-
assert.Equal(c.groupCalls, 1)
60+
assert.Equal(1, c.groupCalls)
6161

6262
cdc.ServerGroups()
6363
assert.True(cdc.Fresh(), "should be fresh after another groups call")
64-
assert.Equal(c.groupCalls, 1)
64+
assert.Equal(1, c.groupCalls)
6565

6666
cdc.ServerGroupsAndResources()
6767
assert.True(cdc.Fresh(), "should be fresh after resources call")
68-
assert.Equal(c.resourceCalls, 1)
68+
assert.Equal(1, c.resourceCalls)
6969

7070
cdc.ServerGroupsAndResources()
7171
assert.True(cdc.Fresh(), "should be fresh after another resources call")
72-
assert.Equal(c.resourceCalls, 1)
72+
assert.Equal(1, c.resourceCalls)
7373

7474
cdc = newCachedDiscoveryClient(&c, d, 60*time.Second)
7575
cdc.ServerGroups()
7676
assert.False(cdc.Fresh(), "should NOT be fresh after recreation with existing groups cache")
77-
assert.Equal(c.groupCalls, 1)
77+
assert.Equal(1, c.groupCalls)
7878

7979
cdc.ServerGroupsAndResources()
8080
assert.False(cdc.Fresh(), "should NOT be fresh after recreation with existing resources cache")
81-
assert.Equal(c.resourceCalls, 1)
81+
assert.Equal(1, c.resourceCalls)
8282

8383
cdc.Invalidate()
8484
assert.True(cdc.Fresh(), "should be fresh after cache invalidation")
8585

8686
cdc.ServerGroupsAndResources()
8787
assert.True(cdc.Fresh(), "should ignore existing resources cache after invalidation")
88-
assert.Equal(c.resourceCalls, 2)
88+
assert.Equal(2, c.resourceCalls)
8989
}
9090

9191
func TestNewCachedDiscoveryClient_TTL(t *testing.T) {
@@ -98,12 +98,12 @@ func TestNewCachedDiscoveryClient_TTL(t *testing.T) {
9898
c := fakeDiscoveryClient{}
9999
cdc := newCachedDiscoveryClient(&c, d, 1*time.Nanosecond)
100100
cdc.ServerGroups()
101-
assert.Equal(c.groupCalls, 1)
101+
assert.Equal(1, c.groupCalls)
102102

103103
time.Sleep(1 * time.Second)
104104

105105
cdc.ServerGroups()
106-
assert.Equal(c.groupCalls, 2)
106+
assert.Equal(2, c.groupCalls)
107107
}
108108

109109
func TestNewCachedDiscoveryClient_PathPerm(t *testing.T) {

staging/src/k8s.io/client-go/features/envvar_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func TestEnvVarFeatureGates(t *testing.T) {
148148
}
149149
for expectedFeature, expectedValue := range scenario.expectedFeaturesState {
150150
actualValue := target.Enabled(expectedFeature)
151-
require.Equal(t, actualValue, expectedValue, "expected feature=%v, to be=%v, not=%v", expectedFeature, expectedValue, actualValue)
151+
require.Equal(t, expectedValue, actualValue, "expected feature=%v, to be=%v, not=%v", expectedFeature, expectedValue, actualValue)
152152
}
153153

154154
enabledViaEnvVarInternalMap := target.enabledViaEnvVar.Load().(map[Feature]bool)

staging/src/k8s.io/client-go/restmapper/discovery_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,24 +257,24 @@ func TestDeferredDiscoveryRESTMapper_CacheMiss(t *testing.T) {
257257
})
258258
assert.NoError(err)
259259
assert.True(cdc.fresh, "should be fresh after a cache-miss")
260-
assert.Equal(cdc.invalidateCalls, 1, "should have called Invalidate() once")
261-
assert.Equal(gvk.Kind, "Foo")
260+
assert.Equal(1, cdc.invalidateCalls, "should have called Invalidate() once")
261+
assert.Equal("Foo", gvk.Kind)
262262

263263
gvk, err = m.KindFor(schema.GroupVersionResource{
264264
Group: "a",
265265
Version: "v1",
266266
Resource: "foo",
267267
})
268268
assert.NoError(err)
269-
assert.Equal(cdc.invalidateCalls, 1, "should NOT have called Invalidate() again")
269+
assert.Equal(1, cdc.invalidateCalls, "should NOT have called Invalidate() again")
270270

271271
gvk, err = m.KindFor(schema.GroupVersionResource{
272272
Group: "a",
273273
Version: "v1",
274274
Resource: "bar",
275275
})
276276
assert.Error(err)
277-
assert.Equal(cdc.invalidateCalls, 1, "should NOT have called Invalidate() again after another cache-miss, but with fresh==true")
277+
assert.Equal(1, cdc.invalidateCalls, "should NOT have called Invalidate() again after another cache-miss, but with fresh==true")
278278

279279
cdc.fresh = false
280280
gvk, err = m.KindFor(schema.GroupVersionResource{
@@ -283,7 +283,7 @@ func TestDeferredDiscoveryRESTMapper_CacheMiss(t *testing.T) {
283283
Resource: "bar",
284284
})
285285
assert.Error(err)
286-
assert.Equal(cdc.invalidateCalls, 2, "should HAVE called Invalidate() again after another cache-miss, but with fresh==false")
286+
assert.Equal(2, cdc.invalidateCalls, "should HAVE called Invalidate() again after another cache-miss, but with fresh==false")
287287
}
288288

289289
func TestGetAPIGroupResources(t *testing.T) {

staging/src/k8s.io/client-go/testing/fixture_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func TestApplyCreate(t *testing.T) {
297297
t.Fatalf("Failed to create a resource with apply: %v", err)
298298
}
299299
cm := configMap.(*v1.ConfigMap)
300-
assert.Equal(t, cm.Data, map[string]string{"k": "v"})
300+
assert.Equal(t, map[string]string{"k": "v"}, cm.Data)
301301
}
302302

303303
func TestApplyNoMeta(t *testing.T) {

staging/src/k8s.io/client-go/util/consistencydetector/data_consistency_detector_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ func TestDataConsistencyChecker(t *testing.T) {
221221
CheckDataConsistency(ctx, "", scenario.lastSyncedResourceVersion, fakeLister.List, scenario.requestOptions, retrievedItemsFunc)
222222
}
223223

224-
require.Equal(t, fakeLister.counter, scenario.expectedListRequests)
225-
require.Equal(t, fakeLister.requestOptions, scenario.expectedRequestOptions)
224+
require.Equal(t, scenario.expectedListRequests, fakeLister.counter)
225+
require.Equal(t, scenario.expectedRequestOptions, fakeLister.requestOptions)
226226
})
227227
}
228228
}

staging/src/k8s.io/client-go/util/consistencydetector/list_data_consistency_detector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func TestCheckListFromCacheDataConsistencyIfRequestedInternalHappyPath(t *testin
133133

134134
require.Equal(t, 1, fakeLister.counter)
135135
require.Len(t, fakeLister.requestOptions, 1)
136-
require.Equal(t, fakeLister.requestOptions[0], scenario.expectedRequestOptions)
136+
require.Equal(t, scenario.expectedRequestOptions, fakeLister.requestOptions[0])
137137
})
138138
}
139139
}

0 commit comments

Comments
 (0)