@@ -202,6 +202,27 @@ func Test_UnmarshallConfig(t *testing.T) {
202202 installNamespace : "not-some-namespace" ,
203203 expectedErrMessage : "required field \" watchNamespace\" is missing" ,
204204 },
205+ {
206+ name : "rejects with required field error when install modes {SingleNamespace} and watchNamespace is missing" ,
207+ supportedInstallModes : []v1alpha1.InstallModeType {v1alpha1 .InstallModeTypeSingleNamespace },
208+ rawConfig : []byte (`{}` ),
209+ installNamespace : "not-some-namespace" ,
210+ expectedErrMessage : "required field \" watchNamespace\" is missing" ,
211+ },
212+ {
213+ name : "rejects with required field error when install modes {SingleNamespace, OwnNamespace} and watchNamespace is missing" ,
214+ supportedInstallModes : []v1alpha1.InstallModeType {v1alpha1 .InstallModeTypeSingleNamespace , v1alpha1 .InstallModeTypeOwnNamespace },
215+ rawConfig : []byte (`{}` ),
216+ installNamespace : "not-some-namespace" ,
217+ expectedErrMessage : "required field \" watchNamespace\" is missing" ,
218+ },
219+ {
220+ name : "rejects with required field error when install modes {SingleNamespace, MultiNamespace} and watchNamespace is missing" ,
221+ supportedInstallModes : []v1alpha1.InstallModeType {v1alpha1 .InstallModeTypeSingleNamespace , v1alpha1 .InstallModeTypeMultiNamespace },
222+ rawConfig : []byte (`{}` ),
223+ installNamespace : "not-some-namespace" ,
224+ expectedErrMessage : "required field \" watchNamespace\" is missing" ,
225+ },
205226 {
206227 name : "rejects with required field error when install modes {SingleNamespace, OwnNamespace, MultiNamespace} and watchNamespace is nil" ,
207228 supportedInstallModes : []v1alpha1.InstallModeType {v1alpha1 .InstallModeTypeSingleNamespace , v1alpha1 .InstallModeTypeOwnNamespace , v1alpha1 .InstallModeTypeMultiNamespace },
@@ -227,6 +248,24 @@ func Test_UnmarshallConfig(t *testing.T) {
227248 WatchNamespace : nil ,
228249 },
229250 },
251+ {
252+ name : "accepts no watchNamespace when install modes {AllNamespaces, OwnNamespace} and watchNamespace is nil" ,
253+ supportedInstallModes : []v1alpha1.InstallModeType {v1alpha1 .InstallModeTypeAllNamespaces , v1alpha1 .InstallModeTypeOwnNamespace },
254+ rawConfig : []byte (`{}` ),
255+ installNamespace : "not-some-namespace" ,
256+ expectedConfig : & bundle.Config {
257+ WatchNamespace : nil ,
258+ },
259+ },
260+ {
261+ name : "accepts no watchNamespace when install modes {AllNamespaces, OwnNamespace, MultiNamespace} and watchNamespace is nil" ,
262+ supportedInstallModes : []v1alpha1.InstallModeType {v1alpha1 .InstallModeTypeAllNamespaces , v1alpha1 .InstallModeTypeOwnNamespace , v1alpha1 .InstallModeTypeMultiNamespace },
263+ rawConfig : []byte (`{}` ),
264+ installNamespace : "not-some-namespace" ,
265+ expectedConfig : & bundle.Config {
266+ WatchNamespace : nil ,
267+ },
268+ },
230269 {
231270 name : "rejects with format error when install modes are {SingleNamespace, OwnNamespace} and watchNamespace is ''" ,
232271 supportedInstallModes : []v1alpha1.InstallModeType {v1alpha1 .InstallModeTypeSingleNamespace , v1alpha1 .InstallModeTypeOwnNamespace },
0 commit comments