Skip to content

Commit 0c35ede

Browse files
committed
add test case for Start function bug
1 parent 49d60ff commit 0c35ede

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/manager/manager_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,22 @@ var _ = Describe("manger.Manager", func() {
11651165
cm.onStoppedLeading = func() {}
11661166
},
11671167
)
1168+
1169+
It("should return an error if leader election param incorrect", func() {
1170+
renewDeadline := time.Second * 20
1171+
m, err := New(cfg, Options{
1172+
LeaderElection: true,
1173+
LeaderElectionID: "controller-runtime",
1174+
LeaderElectionNamespace: "default",
1175+
newResourceLock: fakeleaderelection.NewResourceLock,
1176+
RenewDeadline: &renewDeadline,
1177+
})
1178+
Expect(err).NotTo(HaveOccurred())
1179+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
1180+
defer cancel()
1181+
Expect(m.Start(ctx)).To(HaveOccurred())
1182+
Expect(errors.Is(err, context.DeadlineExceeded)).NotTo(BeTrue())
1183+
})
11681184
})
11691185

11701186
Context("should start serving metrics", func() {

0 commit comments

Comments
 (0)