Skip to content

Commit

Permalink
Fix failing unit tests due to upgrade of controller-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Rizwana777 committed Mar 28, 2024
1 parent 196356c commit 1055ec5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 1 addition & 3 deletions controllers/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -165,9 +164,8 @@ var _ = Describe("ReconcileRolloutManager tests", func() {
Namespace: a.Namespace,
},
}
resources := []runtime.Object{a}

r := makeTestReconciler(resources...)
r := makeTestReconciler(a)
err := createNamespace(r, a.Namespace)
Expect(err).ToNot(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion controllers/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var _ = Describe("RolloutManager Test", func() {
deploy.Status.ReadyReplicas = 1
deploy.Spec.Replicas = &requiredReplicas

Expect(r.Client.Update(ctx, deploy)).To(Succeed())
Expect(r.Client.Status().Update(ctx, deploy)).To(Succeed())
Expect(r.reconcileStatus(ctx, a)).To(Succeed())

Expect(a.Status.RolloutController).To(Equal(rolloutsmanagerv1alpha1.PhaseAvailable))
Expand Down
7 changes: 4 additions & 3 deletions controllers/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand All @@ -32,13 +32,14 @@ func makeTestRolloutManager(opts ...rolloutManagerOpt) *rolloutsmanagerv1alpha1.
return a
}

func makeTestReconciler(objs ...runtime.Object) *RolloutManagerReconciler {
func makeTestReconciler(obj ...client.Object) *RolloutManagerReconciler {
s := scheme.Scheme

err := rolloutsmanagerv1alpha1.AddToScheme(s)
Expect(err).ToNot(HaveOccurred())

cl := fake.NewClientBuilder().WithScheme(s).WithRuntimeObjects(objs...).Build()
cl := fake.NewClientBuilder().WithScheme(s).WithStatusSubresource(obj...).WithObjects(obj...).Build()

return &RolloutManagerReconciler{
Client: cl,
Scheme: s,
Expand Down

0 comments on commit 1055ec5

Please sign in to comment.