diff --git a/discovery/cached/disk/cached_discovery_test.go b/discovery/cached/disk/cached_discovery_test.go index e95eb13cb3..9b197fa31d 100644 --- a/discovery/cached/disk/cached_discovery_test.go +++ b/discovery/cached/disk/cached_discovery_test.go @@ -57,35 +57,35 @@ func TestCachedDiscoveryClient_Fresh(t *testing.T) { cdc.ServerGroups() assert.True(cdc.Fresh(), "should be fresh after groups call without cache") - assert.Equal(c.groupCalls, 1) + assert.Equal(1, c.groupCalls) cdc.ServerGroups() assert.True(cdc.Fresh(), "should be fresh after another groups call") - assert.Equal(c.groupCalls, 1) + assert.Equal(1, c.groupCalls) cdc.ServerGroupsAndResources() assert.True(cdc.Fresh(), "should be fresh after resources call") - assert.Equal(c.resourceCalls, 1) + assert.Equal(1, c.resourceCalls) cdc.ServerGroupsAndResources() assert.True(cdc.Fresh(), "should be fresh after another resources call") - assert.Equal(c.resourceCalls, 1) + assert.Equal(1, c.resourceCalls) cdc = newCachedDiscoveryClient(&c, d, 60*time.Second) cdc.ServerGroups() assert.False(cdc.Fresh(), "should NOT be fresh after recreation with existing groups cache") - assert.Equal(c.groupCalls, 1) + assert.Equal(1, c.groupCalls) cdc.ServerGroupsAndResources() assert.False(cdc.Fresh(), "should NOT be fresh after recreation with existing resources cache") - assert.Equal(c.resourceCalls, 1) + assert.Equal(1, c.resourceCalls) cdc.Invalidate() assert.True(cdc.Fresh(), "should be fresh after cache invalidation") cdc.ServerGroupsAndResources() assert.True(cdc.Fresh(), "should ignore existing resources cache after invalidation") - assert.Equal(c.resourceCalls, 2) + assert.Equal(2, c.resourceCalls) } func TestNewCachedDiscoveryClient_TTL(t *testing.T) { @@ -98,12 +98,12 @@ func TestNewCachedDiscoveryClient_TTL(t *testing.T) { c := fakeDiscoveryClient{} cdc := newCachedDiscoveryClient(&c, d, 1*time.Nanosecond) cdc.ServerGroups() - assert.Equal(c.groupCalls, 1) + assert.Equal(1, c.groupCalls) time.Sleep(1 * time.Second) cdc.ServerGroups() - assert.Equal(c.groupCalls, 2) + assert.Equal(2, c.groupCalls) } func TestNewCachedDiscoveryClient_PathPerm(t *testing.T) { diff --git a/features/envvar_test.go b/features/envvar_test.go index 87a12da592..b032d06cf0 100644 --- a/features/envvar_test.go +++ b/features/envvar_test.go @@ -148,7 +148,7 @@ func TestEnvVarFeatureGates(t *testing.T) { } for expectedFeature, expectedValue := range scenario.expectedFeaturesState { actualValue := target.Enabled(expectedFeature) - require.Equal(t, actualValue, expectedValue, "expected feature=%v, to be=%v, not=%v", expectedFeature, expectedValue, actualValue) + require.Equal(t, expectedValue, actualValue, "expected feature=%v, to be=%v, not=%v", expectedFeature, expectedValue, actualValue) } enabledViaEnvVarInternalMap := target.enabledViaEnvVar.Load().(map[Feature]bool) diff --git a/go.mod b/go.mod index 8fd6f053e5..b6ded58379 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( google.golang.org/protobuf v1.34.2 gopkg.in/evanphx/json-patch.v4 v4.12.0 k8s.io/api v0.0.0-20240920202009-71385f038c10 - k8s.io/apimachinery v0.0.0-20240926041705-dc03077c038e + k8s.io/apimachinery v0.0.0-20240929035808-0db5dbf03048 k8s.io/klog/v2 v2.130.1 k8s.io/kube-openapi v0.0.0-20240827152857-f7e401e7b4c2 k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 diff --git a/go.sum b/go.sum index 9549a3052d..d4a40a7dcc 100644 --- a/go.sum +++ b/go.sum @@ -157,8 +157,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/api v0.0.0-20240920202009-71385f038c10 h1:shjQe98Co9zBlDzQkxb5IJEWtReSl7qunr56C4Jgc70= k8s.io/api v0.0.0-20240920202009-71385f038c10/go.mod h1:KCEt6+W/Yn1Vc48pYXeLf0mGK52kJhvt+rcaUVsIaKQ= -k8s.io/apimachinery v0.0.0-20240926041705-dc03077c038e h1:/N2qUkIcQ8VaZbmy28grdhVBbNXO6KLZRdz6F2siNeY= -k8s.io/apimachinery v0.0.0-20240926041705-dc03077c038e/go.mod h1:5rKPDwwN9qm//xASFCZ83nyYEanHxxhc7pZ8AC4lukY= +k8s.io/apimachinery v0.0.0-20240929035808-0db5dbf03048 h1:EWQWppfphUSBwuhuNA4weJ9vJtfHhjVwizTYjZb8ikw= +k8s.io/apimachinery v0.0.0-20240929035808-0db5dbf03048/go.mod h1:5rKPDwwN9qm//xASFCZ83nyYEanHxxhc7pZ8AC4lukY= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240827152857-f7e401e7b4c2 h1:GKE9U8BH16uynoxQii0auTjmmmuZ3O0LFMN6S0lPPhI= diff --git a/restmapper/discovery_test.go b/restmapper/discovery_test.go index b0c90fe19c..5df045f9cf 100644 --- a/restmapper/discovery_test.go +++ b/restmapper/discovery_test.go @@ -257,8 +257,8 @@ func TestDeferredDiscoveryRESTMapper_CacheMiss(t *testing.T) { }) assert.NoError(err) assert.True(cdc.fresh, "should be fresh after a cache-miss") - assert.Equal(cdc.invalidateCalls, 1, "should have called Invalidate() once") - assert.Equal(gvk.Kind, "Foo") + assert.Equal(1, cdc.invalidateCalls, "should have called Invalidate() once") + assert.Equal("Foo", gvk.Kind) gvk, err = m.KindFor(schema.GroupVersionResource{ Group: "a", @@ -266,7 +266,7 @@ func TestDeferredDiscoveryRESTMapper_CacheMiss(t *testing.T) { Resource: "foo", }) assert.NoError(err) - assert.Equal(cdc.invalidateCalls, 1, "should NOT have called Invalidate() again") + assert.Equal(1, cdc.invalidateCalls, "should NOT have called Invalidate() again") gvk, err = m.KindFor(schema.GroupVersionResource{ Group: "a", @@ -274,7 +274,7 @@ func TestDeferredDiscoveryRESTMapper_CacheMiss(t *testing.T) { Resource: "bar", }) assert.Error(err) - assert.Equal(cdc.invalidateCalls, 1, "should NOT have called Invalidate() again after another cache-miss, but with fresh==true") + assert.Equal(1, cdc.invalidateCalls, "should NOT have called Invalidate() again after another cache-miss, but with fresh==true") cdc.fresh = false gvk, err = m.KindFor(schema.GroupVersionResource{ @@ -283,7 +283,7 @@ func TestDeferredDiscoveryRESTMapper_CacheMiss(t *testing.T) { Resource: "bar", }) assert.Error(err) - assert.Equal(cdc.invalidateCalls, 2, "should HAVE called Invalidate() again after another cache-miss, but with fresh==false") + assert.Equal(2, cdc.invalidateCalls, "should HAVE called Invalidate() again after another cache-miss, but with fresh==false") } func TestGetAPIGroupResources(t *testing.T) { diff --git a/testing/fixture_test.go b/testing/fixture_test.go index 9d6d529338..0954edc573 100644 --- a/testing/fixture_test.go +++ b/testing/fixture_test.go @@ -297,7 +297,7 @@ func TestApplyCreate(t *testing.T) { t.Fatalf("Failed to create a resource with apply: %v", err) } cm := configMap.(*v1.ConfigMap) - assert.Equal(t, cm.Data, map[string]string{"k": "v"}) + assert.Equal(t, map[string]string{"k": "v"}, cm.Data) } func TestApplyNoMeta(t *testing.T) { diff --git a/util/consistencydetector/data_consistency_detector_test.go b/util/consistencydetector/data_consistency_detector_test.go index 300e8d9ea0..bdac197a75 100644 --- a/util/consistencydetector/data_consistency_detector_test.go +++ b/util/consistencydetector/data_consistency_detector_test.go @@ -221,8 +221,8 @@ func TestDataConsistencyChecker(t *testing.T) { CheckDataConsistency(ctx, "", scenario.lastSyncedResourceVersion, fakeLister.List, scenario.requestOptions, retrievedItemsFunc) } - require.Equal(t, fakeLister.counter, scenario.expectedListRequests) - require.Equal(t, fakeLister.requestOptions, scenario.expectedRequestOptions) + require.Equal(t, scenario.expectedListRequests, fakeLister.counter) + require.Equal(t, scenario.expectedRequestOptions, fakeLister.requestOptions) }) } } diff --git a/util/consistencydetector/list_data_consistency_detector_test.go b/util/consistencydetector/list_data_consistency_detector_test.go index a4bd8c9cdf..e84d47a28d 100644 --- a/util/consistencydetector/list_data_consistency_detector_test.go +++ b/util/consistencydetector/list_data_consistency_detector_test.go @@ -133,7 +133,7 @@ func TestCheckListFromCacheDataConsistencyIfRequestedInternalHappyPath(t *testin require.Equal(t, 1, fakeLister.counter) require.Len(t, fakeLister.requestOptions, 1) - require.Equal(t, fakeLister.requestOptions[0], scenario.expectedRequestOptions) + require.Equal(t, scenario.expectedRequestOptions, fakeLister.requestOptions[0]) }) } }