@@ -19,6 +19,7 @@ func Test_BundleValidatorHasAllValidationFns(t *testing.T) {
1919		convert .CheckDeploymentSpecUniqueness ,
2020		convert .CheckCRDResourceUniqueness ,
2121		convert .CheckOwnedCRDExistence ,
22+ 		convert .CheckPackageNameNotEmpty ,
2223	}
2324	actualValidationFns  :=  convert .RegistryV1BundleValidator 
2425
@@ -60,6 +61,7 @@ func Test_CheckDeploymentSpecUniqueness(t *testing.T) {
6061					),
6162				),
6263			},
64+ 			expectedErrs : []error {},
6365		}, {
6466			name : "rejects bundles with duplicate deployment strategy spec names" ,
6567			bundle : & convert.RegistryV1 {
@@ -114,6 +116,7 @@ func Test_CRDResourceUniqueness(t *testing.T) {
114116					{ObjectMeta : metav1.ObjectMeta {Name : "b.crd.something" }},
115117				},
116118			},
119+ 			expectedErrs : []error {},
117120		}, {
118121			name : "rejects bundles with duplicate custom resource definition resources" ,
119122			bundle : & convert.RegistryV1 {CRDs : []apiextensionsv1.CustomResourceDefinition {
@@ -164,6 +167,7 @@ func Test_CheckOwnedCRDExistence(t *testing.T) {
164167					),
165168				),
166169			},
170+ 			expectedErrs : []error {},
167171		}, {
168172			name : "rejects bundles with missing owned custom resource definition resources" ,
169173			bundle : & convert.RegistryV1 {
@@ -200,3 +204,29 @@ func Test_CheckOwnedCRDExistence(t *testing.T) {
200204		})
201205	}
202206}
207+ 
208+ func  Test_CheckPackageNameNotEmpty (t  * testing.T ) {
209+ 	for  _ , tc  :=  range  []struct  {
210+ 		name          string 
211+ 		bundle        * convert.RegistryV1 
212+ 		expectedErrs  []error 
213+ 	}{
214+ 		{
215+ 			name : "accepts bundles with non-empty package name" ,
216+ 			bundle : & convert.RegistryV1 {
217+ 				PackageName : "not-empty" ,
218+ 			},
219+ 		}, {
220+ 			name :   "rejects bundles with empty package name" ,
221+ 			bundle : & convert.RegistryV1 {},
222+ 			expectedErrs : []error {
223+ 				errors .New ("package name is empty" ),
224+ 			},
225+ 		},
226+ 	} {
227+ 		t .Run (tc .name , func (t  * testing.T ) {
228+ 			errs  :=  convert .CheckPackageNameNotEmpty (tc .bundle )
229+ 			require .Equal (t , tc .expectedErrs , errs )
230+ 		})
231+ 	}
232+ }
0 commit comments