@@ -93,3 +93,65 @@ func TestCloudKittySpecBaseDefault(t *testing.T) {
9393 g .Expect (spec .MessagingBus .Cluster ).To (Equal ("rabbitmq" ),
9494 "CloudKitty messagingBus.cluster should be defaulted to rabbitmq" )
9595}
96+
97+ // TestAodhCoreDefaultWithNilNotificationsBus tests that Default() doesn't panic with nil NotificationsBus
98+ func TestAodhCoreDefaultWithNilNotificationsBus (t * testing.T ) {
99+ g := NewWithT (t )
100+
101+ spec := & AodhCore {}
102+ // NotificationsBus is nil (not set)
103+
104+ // Call Default() - should not panic
105+ spec .Default ()
106+
107+ // NotificationsBus should remain nil
108+ g .Expect (spec .NotificationsBus ).To (BeNil (),
109+ "Aodh notificationsBus should remain nil when not configured" )
110+ }
111+
112+ // TestCeilometerSpecCoreDefaultWithNilNotificationsBus tests that Default() doesn't panic with nil NotificationsBus
113+ func TestCeilometerSpecCoreDefaultWithNilNotificationsBus (t * testing.T ) {
114+ g := NewWithT (t )
115+
116+ spec := & CeilometerSpecCore {}
117+ // NotificationsBus is nil (not set)
118+
119+ // Call Default() - should not panic
120+ spec .Default ()
121+
122+ // NotificationsBus should remain nil
123+ g .Expect (spec .NotificationsBus ).To (BeNil (),
124+ "Ceilometer notificationsBus should remain nil when not configured" )
125+ }
126+
127+ // TestAodhCoreValidateCreateWithNilNotificationsBus tests validation with nil NotificationsBus
128+ func TestAodhCoreValidateCreateWithNilNotificationsBus (t * testing.T ) {
129+ g := NewWithT (t )
130+
131+ spec := & AodhCore {}
132+ // NotificationsBus is nil, but we have the deprecated field set
133+ spec .RabbitMqClusterName = "old-rabbitmq"
134+
135+ // Call ValidateCreate - should not panic even with nil NotificationsBus
136+ warns , errs := spec .ValidateCreate (nil , "default" )
137+
138+ // Should have a warning about deprecated field
139+ g .Expect (warns ).ToNot (BeEmpty (), "Should have warning about deprecated rabbitMqClusterName field" )
140+ g .Expect (errs ).To (BeEmpty (), "Should not have errors" )
141+ }
142+
143+ // TestCeilometerSpecCoreValidateCreateWithNilNotificationsBus tests validation with nil NotificationsBus
144+ func TestCeilometerSpecCoreValidateCreateWithNilNotificationsBus (t * testing.T ) {
145+ g := NewWithT (t )
146+
147+ spec := & CeilometerSpecCore {}
148+ // NotificationsBus is nil, but we have the deprecated field set
149+ spec .RabbitMqClusterName = "old-rabbitmq"
150+
151+ // Call ValidateCreate - should not panic even with nil NotificationsBus
152+ warns , errs := spec .ValidateCreate (nil , "default" )
153+
154+ // Should have a warning about deprecated field
155+ g .Expect (warns ).ToNot (BeEmpty (), "Should have warning about deprecated rabbitMqClusterName field" )
156+ g .Expect (errs ).To (BeEmpty (), "Should not have errors" )
157+ }
0 commit comments