@@ -118,3 +118,61 @@ func TestPackageManifestLoading(t *testing.T) {
118
118
require .NotNil (t , pmList .ListMeta , "package manifest list metadata empty" )
119
119
require .NotNil (t , pmList .Items )
120
120
}
121
+
122
+ func TestPkgManifestsFromCatsrc (t * testing.T ) {
123
+ defer cleaner .NotifyTestComplete (t , true )
124
+
125
+ sourceName := genName ("catalog-" )
126
+ packageName := "etcd-test"
127
+ displayName := "etcd test catalog"
128
+ image := "quay.io/olmtest/catsrc-update-test:related"
129
+ crc := newCRClient (t )
130
+ pmc := newPMClient (t )
131
+
132
+ catalogSource := & v1alpha1.CatalogSource {
133
+ TypeMeta : metav1.TypeMeta {
134
+ Kind : v1alpha1 .CatalogSourceKind ,
135
+ APIVersion : v1alpha1 .CatalogSourceCRDAPIVersion ,
136
+ },
137
+ ObjectMeta : metav1.ObjectMeta {
138
+ Name : sourceName ,
139
+ Namespace : testNamespace ,
140
+ Labels : map [string ]string {"olm.catalogSource" : sourceName },
141
+ },
142
+ Spec : v1alpha1.CatalogSourceSpec {
143
+ SourceType : v1alpha1 .SourceTypeGrpc ,
144
+ Image : image ,
145
+ DisplayName : displayName ,
146
+ },
147
+ }
148
+
149
+ catalogSource , err := crc .OperatorsV1alpha1 ().CatalogSources (catalogSource .GetNamespace ()).Create (catalogSource )
150
+ require .NoError (t , err , "error creating Catalog Sources" )
151
+ require .NotNil (t , catalogSource )
152
+
153
+ pm , err := fetchPackageManifest (t , pmc , testNamespace , packageName , packageManifestHasStatus )
154
+ require .NoError (t , err , "error getting package manifest" )
155
+ require .NotNil (t , pm )
156
+ require .Equal (t , packageName , pm .GetName ())
157
+ require .Equal (t , displayName , pm .Status .CatalogSourceDisplayName )
158
+
159
+ catalogSource , err = crc .OperatorsV1alpha1 ().CatalogSources (testNamespace ).Get (catalogSource .GetName (), metav1.GetOptions {})
160
+ require .NoError (t , err , "error getting catalogSource" )
161
+
162
+ displayName = "updated Name"
163
+ catalogSource .Spec .DisplayName = displayName
164
+ catalogSource , err = crc .OperatorsV1alpha1 ().CatalogSources (testNamespace ).Update (catalogSource )
165
+ require .NoError (t , err , "error updating catalogSource" )
166
+ require .Equal (t , displayName , catalogSource .Spec .DisplayName )
167
+
168
+ // waiting for the update to complete
169
+ err = wait .Poll (pollInterval , 1 * time .Minute , func () (bool , error ) {
170
+ t .Logf ("Polling package-server..." )
171
+ pm , err := fetchPackageManifest (t , pmc , testNamespace , packageName , packageManifestHasStatus )
172
+ if err != nil {
173
+ return false , err
174
+ }
175
+ return pm .Status .CatalogSourceDisplayName == displayName , nil
176
+ })
177
+ require .NoError (t , err , "error package manifest Status.CatalogSourceDisplayName is not updated to catsrc Spec.DisplayName" )
178
+ }
0 commit comments