@@ -148,6 +148,34 @@ var _ = Describe("CleanupCronJobReconciler", func() {
148148 Expect (reconciler .cron .Entries ()).To (BeEmpty ())
149149 })
150150
151+ It ("Should not start cron if dwOperatorConfig.Config is nil" , func () {
152+ dwoc := & controllerv1alpha1.DevWorkspaceOperatorConfig {
153+ ObjectMeta : metav1.ObjectMeta {Name : nameNamespace .Name , Namespace : nameNamespace .Namespace },
154+ Config : nil ,
155+ }
156+ Expect (fakeClient .Create (ctx , dwoc )).To (Succeed ())
157+
158+ result , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : nameNamespace })
159+ Expect (err ).ToNot (HaveOccurred ())
160+ Expect (result ).To (Equal (ctrl.Result {}))
161+ Expect (reconciler .cron .Entries ()).To (BeEmpty ())
162+ })
163+
164+ It ("Should not start cron if dwOperatorConfig.Config.Workspace is nil" , func () {
165+ dwoc := & controllerv1alpha1.DevWorkspaceOperatorConfig {
166+ ObjectMeta : metav1.ObjectMeta {Name : nameNamespace .Name , Namespace : nameNamespace .Namespace },
167+ Config : & controllerv1alpha1.OperatorConfiguration {
168+ Workspace : nil ,
169+ },
170+ }
171+ Expect (fakeClient .Create (ctx , dwoc )).To (Succeed ())
172+
173+ result , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : nameNamespace })
174+ Expect (err ).ToNot (HaveOccurred ())
175+ Expect (result ).To (Equal (ctrl.Result {}))
176+ Expect (reconciler .cron .Entries ()).To (BeEmpty ())
177+ })
178+
151179 It ("Should not start cron if received event from different namespace" , func () {
152180 dwoc := & controllerv1alpha1.DevWorkspaceOperatorConfig {
153181 ObjectMeta : metav1.ObjectMeta {Name : nameNamespace .Name , Namespace : "other-namespace" },
@@ -185,7 +213,7 @@ var _ = Describe("CleanupCronJobReconciler", func() {
185213 Expect (reconciler .cron .Entries ()).To (BeEmpty ())
186214 })
187215
188- It ("Should do not start cron if pruning is disabled" , func () {
216+ It ("Should not start cron if pruning is disabled" , func () {
189217 enabled := false
190218 dwoc := & controllerv1alpha1.DevWorkspaceOperatorConfig {
191219 ObjectMeta : metav1.ObjectMeta {Name : nameNamespace .Name , Namespace : nameNamespace .Namespace },
@@ -205,7 +233,7 @@ var _ = Describe("CleanupCronJobReconciler", func() {
205233 Expect (reconciler .cron .Entries ()).To (BeEmpty ())
206234 })
207235
208- It ("Should do not start cron if schedule is missing" , func () {
236+ It ("Should not start cron if schedule is missing" , func () {
209237 enabled := true
210238 dwoc := & controllerv1alpha1.DevWorkspaceOperatorConfig {
211239 ObjectMeta : metav1.ObjectMeta {Name : nameNamespace .Name , Namespace : nameNamespace .Namespace },
0 commit comments