Skip to content

Commit

Permalink
simplify mock setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
seizethedave committed Jun 4, 2024
1 parent 826bc13 commit 2b7d6ad
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/admission/prep_downscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/fake"
fakeappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1/fake"
k8stesting "k8s.io/client-go/testing"

"github.com/grafana/rollout-operator/pkg/config"
Expand Down Expand Up @@ -309,8 +308,7 @@ func testPrepDownscaleWebhook(t *testing.T, oldReplicas, newReplicas int, option
api := fake.NewSimpleClientset(objects...)

if params.failSetLastDownscale {
f := api.AppsV1().(*fakeappsv1.FakeAppsV1)
f.PrependReactor("patch", "statefulsets", func(action k8stesting.Action) (bool, runtime.Object, error) {
api.PrependReactor("patch", "statefulsets", func(action k8stesting.Action) (bool, runtime.Object, error) {
return true, nil, errors.New("something terrible happened")
})
}
Expand Down Expand Up @@ -785,8 +783,7 @@ func testPrepDownscaleWebhookWithZoneTracker(t *testing.T, oldReplicas, newRepli
api := fake.NewSimpleClientset(objects...)

if params.failSetLastDownscale {
f := api.AppsV1().(*fakeappsv1.FakeAppsV1)
f.PrependReactor("update", "configmaps", func(action k8stesting.Action) (bool, runtime.Object, error) {
api.PrependReactor("update", "configmaps", func(action k8stesting.Action) (bool, runtime.Object, error) {
return true, nil, errors.New("something terrible happened")
})
}
Expand Down

0 comments on commit 2b7d6ad

Please sign in to comment.