Skip to content

Commit

Permalink
Tell the linter to ignore the use of the newly deprecated methods. We…
Browse files Browse the repository at this point in the history
… only

use them in tests and in places that actually test the deprecated
functionality.
This will be removed in the future.
  • Loading branch information
metlos committed Mar 15, 2024
1 parent dd69782 commit 03de45f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
5 changes: 2 additions & 3 deletions controllers/toolchainconfig/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 6 additions & 9 deletions controllers/toolchainconfig/toolchainconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 03de45f

Please sign in to comment.