From 03de45fd89e8da6b57f348504caf4f04f565bfe5 Mon Sep 17 00:00:00 2001 From: Lukas Krejci Date: Fri, 15 Mar 2024 17:25:03 +0100 Subject: [PATCH] Tell the linter to ignore the use of the newly deprecated methods. We only use them in tests and in places that actually test the deprecated functionality. This will be removed in the future. --- controllers/toolchainconfig/configuration_test.go | 5 ++--- .../toolchainconfig_controller_test.go | 15 ++++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/controllers/toolchainconfig/configuration_test.go b/controllers/toolchainconfig/configuration_test.go index 48d6eef94..0c3a57340 100644 --- a/controllers/toolchainconfig/configuration_test.go +++ b/controllers/toolchainconfig/configuration_test.go @@ -181,7 +181,6 @@ func TestForceLoadToolchainConfig(t *testing.T) { assert.Equal(t, "unit-tests", toolchainCfg.Environment()) // returns actual value assert.Equal(t, "def456", toolchainCfg.Notifications().MailgunAPIKey()) // returns actual value }) - }) t.Run("error retrieving config object", func(t *testing.T) { @@ -260,7 +259,7 @@ func TestCapacityThresholdsConfig(t *testing.T) { assert.Empty(t, toolchainCfg.CapacityThresholds().ResourceCapacityThresholdSpecificPerMemberCluster()) }) t.Run("non-default", func(t *testing.T) { - cfg := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)).ResourceCapacityThreshold(456, testconfig.PerMemberCluster("member1", 654))) + cfg := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)).ResourceCapacityThreshold(456, testconfig.PerMemberCluster("member1", 654))) //nolint:staticcheck // this will be removed once we also remove the deprecated method toolchainCfg := newToolchainConfig(cfg, map[string]map[string]string{}) assert.Equal(t, cfg.Spec.Host.CapacityThresholds.MaxNumberOfSpacesPerMemberCluster, toolchainCfg.CapacityThresholds().MaxNumberOfSpacesSpecificPerMemberCluster()) @@ -336,7 +335,7 @@ func TestNotifications(t *testing.T) { assert.Empty(t, toolchainCfg.Notifications().MailgunReplyToEmail()) assert.Equal(t, "mailgun", toolchainCfg.Notifications().NotificationDeliveryService()) assert.Equal(t, 24*time.Hour, toolchainCfg.Notifications().DurationBeforeNotificationDeletion()) - assert.Equal(t, "sandbox", toolchainCfg.Notifications().TemplateSetName()) //default notificationEnv + assert.Equal(t, "sandbox", toolchainCfg.Notifications().TemplateSetName()) // default notificationEnv }) t.Run("non-default", func(t *testing.T) { cfg := commonconfig.NewToolchainConfigObjWithReset(t, diff --git a/controllers/toolchainconfig/toolchainconfig_controller_test.go b/controllers/toolchainconfig/toolchainconfig_controller_test.go index 204387bee..0deb94ee6 100644 --- a/controllers/toolchainconfig/toolchainconfig_controller_test.go +++ b/controllers/toolchainconfig/toolchainconfig_controller_test.go @@ -34,7 +34,6 @@ func TestReconcile(t *testing.T) { specificMemberConfig := testconfig.NewMemberOperatorConfigObj(testconfig.MemberStatus().RefreshPeriod("10s")) t.Run("success", func(t *testing.T) { - t.Run("config not found", func(t *testing.T) { hostCl := test.NewFakeClient(t) member1 := NewMemberClusterWithTenantRole(t, "member1", corev1.ConditionTrue) @@ -62,13 +61,12 @@ func TestReconcile(t *testing.T) { _, err = getMemberConfig(member2) assert.Error(t, err) assert.True(t, errors.IsNotFound(err)) - }) t.Run("config exists", func(t *testing.T) { config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)), + testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)), //nolint:staticcheck // this will be removed once we also remove the deprecated method testconfig.Members().Default(defaultMemberConfig.Spec), testconfig.Members().SpecificPerMemberCluster("member1", specificMemberConfig.Spec)) hostCl := test.NewFakeClient(t, config) @@ -182,12 +180,11 @@ func TestReconcile(t *testing.T) { }) t.Run("failures", func(t *testing.T) { - t.Run("error getting the toolchainconfig resource", func(t *testing.T) { // given config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)), + testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)), //nolint:staticcheck // this will be removed once we also remove the deprecated method testconfig.Members().Default(defaultMemberConfig.Spec), testconfig.Members().SpecificPerMemberCluster("member1", specificMemberConfig.Spec)) hostCl := test.NewFakeClient(t, config) @@ -216,7 +213,7 @@ func TestReconcile(t *testing.T) { // given config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)), + testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321)), //nolint:staticcheck // this will be removed once we also remove the deprecated method testconfig.Members().Default(defaultMemberConfig.Spec), testconfig.Members().SpecificPerMemberCluster("member1", specificMemberConfig.Spec)) hostCl := test.NewFakeClient(t, config) @@ -248,7 +245,7 @@ func TestReconcile(t *testing.T) { // given config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321))) + testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321))) //nolint:staticcheck // this will be removed once we also remove the deprecated method hostCl := test.NewFakeClient(t, config) hostCl.MockCreate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.CreateOption) error { return fmt.Errorf("create error") @@ -276,7 +273,7 @@ func TestReconcile(t *testing.T) { t.Run("sync failed", func(t *testing.T) { // given config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), testconfig.Members().Default(defaultMemberConfig.Spec), testconfig.Members().SpecificPerMemberCluster("missing-member", specificMemberConfig.Spec), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321))) + testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321))) //nolint:staticcheck // this will be removed once we also remove the deprecated method hostCl := test.NewFakeClient(t, config) members := NewGetMemberClusters(NewMemberClusterWithTenantRole(t, "member1", corev1.ConditionTrue), NewMemberClusterWithTenantRole(t, "member2", corev1.ConditionTrue)) controller := newController(t, hostCl, members) @@ -305,7 +302,7 @@ func TestReconcile(t *testing.T) { func TestWrapErrorWithUpdateStatus(t *testing.T) { // given config := commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true), - testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321))) + testconfig.CapacityThresholds().MaxNumberOfSpaces(testconfig.PerMemberCluster("member1", 321))) //nolint:staticcheck // this will be removed once we also remove the deprecated method hostCl := test.NewFakeClient(t, config) members := NewGetMemberClusters(NewMemberClusterWithTenantRole(t, "member1", corev1.ConditionTrue), NewMemberClusterWithTenantRole(t, "member2", corev1.ConditionTrue)) controller := newController(t, hostCl, members)