Skip to content

Commit

Permalink
adapt upstream mocktest branch changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amold1 committed Apr 23, 2024
1 parent fbf17de commit 51bf249
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions controller/linodecluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
},
}

ctlrSuite := NewControllerTestSuite(mock.MockLinodeNodeBalancerClient{})
ctlrSuite := NewControllerTestSuite(GinkgoT(), mock.MockLinodeNodeBalancerClient{})
reconciler := LinodeClusterReconciler{
Recorder: ctlrSuite.Recorder(),
}
Expand Down Expand Up @@ -108,7 +108,7 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
NodeBalancerID: nodebalancerID,
}, nil)
}),
Case(
Path(
Call("cluster is not created because there is no nb", func(ctx context.Context, m Mock) {
cScope.LinodeClient = m.NodeBalancerClient
getNB := m.NodeBalancerClient.EXPECT().ListNodeBalancers(gomock.Any(), gomock.Any()).Return(nil, nil)
Expand All @@ -121,7 +121,7 @@ var _ = Describe("cluster-lifecycle", Ordered, Label("cluster", "cluster-lifecyc
Expect(err.Error()).To(ContainSubstring("create NB error"))
}),
),
Case(
Path(
Call("cluster is not created because there is no capl cluster", func(ctx context.Context, m Mock) {
cScope.LinodeClient = m.NodeBalancerClient
}),
Expand Down Expand Up @@ -184,6 +184,7 @@ var _ = Describe("cluster-delete", Ordered, Label("cluster", "cluster-delete"),
}

ctlrSuite := NewControllerTestSuite(
GinkgoT(),
mock.MockLinodeNodeBalancerClient{},
mock.MockK8sClient{},
)
Expand All @@ -202,21 +203,20 @@ var _ = Describe("cluster-delete", Ordered, Label("cluster", "cluster-delete"),
cScope.Client = m.K8sClient
m.NodeBalancerClient.EXPECT().DeleteNodeBalancer(gomock.Any(), gomock.Any()).Return(nil)
}),
Case(
Path(
Call("nothing to do because NB ID is nil", func(ctx context.Context, m Mock) {
cScope.Client = m.K8sClient
cScope.LinodeClient = m.NodeBalancerClient
cScope.LinodeCluster.Spec.Network.NodeBalancerID = nil
// m.NodeBalancerClient.EXPECT().DeleteNodeBalancer(gomock.Any(), gomock.Any()).Return(nil)
}),
Result("nothing to do because NB ID is nil", func(ctx context.Context, m Mock) {
reconciler.Client = m.K8sClient
err := reconciler.reconcileDelete(ctx, logr.Logger{}, cScope)
Expect(err).NotTo(HaveOccurred())
Expect(<-m.Events()).To(ContainSubstring("Warning NodeBalancerIDMissing NodeBalancer ID is missing, nothing to do"))
Expect(ctlrSuite.Events()).To(ContainSubstring("Warning NodeBalancerIDMissing NodeBalancer ID is missing, nothing to do"))
}),
),
Case(
Path(
Call("cluster not deleted because the nb can't be deleted", func(ctx context.Context, m Mock) {
cScope.LinodeClient = m.NodeBalancerClient
cScope.Client = m.K8sClient
Expand Down

0 comments on commit 51bf249

Please sign in to comment.