3030 "applierContainerImageURL" : "watcher-applier-custom-image" ,
3131 "decisionengineContainerImageURL" : "watcher-decision-engine-custom-image" ,
3232 }
33+
34+ MinimalWatcherEmptyDatabaseSpec = map [string ]interface {}{
35+ "databaseInstance" : "" ,
36+ }
37+
38+ MinimalWatcherEmptyRabbitMqSpec = map [string ]interface {}{
39+ "rabbitMqClusterName" : "" ,
40+ }
3341)
3442
3543var _ = Describe ("Watcher controller with minimal spec values" , func () {
@@ -40,11 +48,11 @@ var _ = Describe("Watcher controller with minimal spec values", func() {
4048
4149 It ("should have the Spec fields defaulted" , func () {
4250 Watcher := GetWatcher (watcherTest .Instance )
43- Expect (Watcher .Spec .DatabaseInstance ).Should (Equal ("openstack" ))
51+ Expect (* ( Watcher .Spec .DatabaseInstance ) ).Should (Equal ("openstack" ))
4452 Expect (Watcher .Spec .DatabaseAccount ).Should (Equal ("watcher" ))
4553 Expect (Watcher .Spec .Secret ).Should (Equal ("osp-secret" ))
4654 Expect (Watcher .Spec .PasswordSelectors ).Should (Equal (watcherv1beta1.PasswordSelector {Service : "WatcherPassword" }))
47- Expect (Watcher .Spec .RabbitMqClusterName ).Should (Equal ("rabbitmq" ))
55+ Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
4856 Expect (Watcher .Spec .ServiceUser ).Should (Equal ("watcher" ))
4957 Expect (Watcher .Spec .PreserveJobs ).Should (BeFalse ())
5058 })
@@ -82,11 +90,11 @@ var _ = Describe("Watcher controller", func() {
8290
8391 It ("should have the Spec fields defaulted" , func () {
8492 Watcher := GetWatcher (watcherTest .Instance )
85- Expect (Watcher .Spec .DatabaseInstance ).Should (Equal ("openstack" ))
93+ Expect (* ( Watcher .Spec .DatabaseInstance ) ).Should (Equal ("openstack" ))
8694 Expect (Watcher .Spec .DatabaseAccount ).Should (Equal ("watcher" ))
8795 Expect (Watcher .Spec .ServiceUser ).Should (Equal ("watcher" ))
8896 Expect (Watcher .Spec .Secret ).Should (Equal ("test-osp-secret" ))
89- Expect (Watcher .Spec .RabbitMqClusterName ).Should (Equal ("rabbitmq" ))
97+ Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
9098 Expect (Watcher .Spec .PreserveJobs ).Should (BeFalse ())
9199 })
92100
@@ -188,7 +196,7 @@ var _ = Describe("Watcher controller", func() {
188196 mariadb .DeleteDBService ,
189197 mariadb .CreateDBService (
190198 watcherTest .Instance .Namespace ,
191- GetWatcher (watcherTest .Instance ).Spec .DatabaseInstance ,
199+ * GetWatcher (watcherTest .Instance ).Spec .DatabaseInstance ,
192200 corev1.ServiceSpec {
193201 Ports : []corev1.ServicePort {{Port : 3306 }},
194202 },
@@ -422,7 +430,7 @@ var _ = Describe("Watcher controller", func() {
422430 mariadb .DeleteDBService ,
423431 mariadb .CreateDBService (
424432 watcherTest .Instance .Namespace ,
425- GetWatcher (watcherTest .Instance ).Spec .DatabaseInstance ,
433+ * GetWatcher (watcherTest .Instance ).Spec .DatabaseInstance ,
426434 corev1.ServiceSpec {
427435 Ports : []corev1.ServicePort {{Port : 3306 }},
428436 },
@@ -494,6 +502,26 @@ var _ = Describe("Watcher controller", func() {
494502 Expect (Watcher .Spec .ApplierContainerImageURL ).To (Equal ("watcher-applier-custom-image-env" ))
495503 })
496504 })
505+
506+ When ("Watcher is created with empty databaseinstance" , func () {
507+ BeforeEach (func () {
508+ DeferCleanup (th .DeleteInstance , CreateWatcher (watcherTest .Instance , MinimalWatcherEmptyDatabaseSpec ))
509+ })
510+ It ("It should raise error for empty databaseInstance" , func () {
511+ err := GetWatcher (watcherTest .Instance )
512+ Expect (err ).To (HaveOccurred ())
513+ })
514+ })
515+
516+ When ("Watcher is created with empty RabbitMqClusterName" , func () {
517+ BeforeEach (func () {
518+ DeferCleanup (th .DeleteInstance , CreateWatcher (watcherTest .Instance , MinimalWatcherEmptyRabbitMqSpec ))
519+ })
520+ It ("It should raise error for empty rabbitMqClusterName" , func () {
521+ err := GetWatcher (watcherTest .Instance )
522+ Expect (err ).To (HaveOccurred ())
523+ })
524+ })
497525 When ("Watcher with non-default values are created" , func () {
498526 BeforeEach (func () {
499527 DeferCleanup (th .DeleteInstance , CreateWatcher (watcherTest .Instance , GetNonDefaultWatcherSpec ()))
@@ -502,7 +530,7 @@ var _ = Describe("Watcher controller", func() {
502530 mariadb .DeleteDBService ,
503531 mariadb .CreateDBService (
504532 watcherTest .Instance .Namespace ,
505- GetWatcher (watcherTest .Instance ).Spec .DatabaseInstance ,
533+ * GetWatcher (watcherTest .Instance ).Spec .DatabaseInstance ,
506534 corev1.ServiceSpec {
507535 Ports : []corev1.ServicePort {{Port : 3306 }},
508536 },
@@ -512,12 +540,12 @@ var _ = Describe("Watcher controller", func() {
512540
513541 It ("should have the Spec fields with the expected values" , func () {
514542 Watcher := GetWatcher (watcherTest .Instance )
515- Expect (Watcher .Spec .DatabaseInstance ).Should (Equal ("fakeopenstack" ))
543+ Expect (* ( Watcher .Spec .DatabaseInstance ) ).Should (Equal ("fakeopenstack" ))
516544 Expect (Watcher .Spec .DatabaseAccount ).Should (Equal ("watcher" ))
517545 Expect (Watcher .Spec .ServiceUser ).Should (Equal ("fakeuser" ))
518546 Expect (Watcher .Spec .Secret ).Should (Equal ("test-osp-secret" ))
519547 Expect (Watcher .Spec .PreserveJobs ).Should (BeTrue ())
520- Expect (Watcher .Spec .RabbitMqClusterName ).Should (Equal ("rabbitmq" ))
548+ Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
521549 })
522550
523551 It ("Should create watcher service with custom values" , func () {
0 commit comments