@@ -175,11 +175,8 @@ func TestGoCSVUpgradeWithInputsToOutput(t *testing.T) {
175
175
176
176
// Read generated CSV from outputDir path
177
177
csvOutputFile := filepath .Join (outputFromCSVDir , csvVersion , csvFileName )
178
-
179
178
outputCSV := getCSVFromFile (t , csvOutputFile )
180
-
181
179
removeSDKstampsFromCSVHelper (outputCSV )
182
-
183
180
expCSV := getCSVFromFile (t , expCsvFile )
184
181
185
182
assert .Equal (t , expCSV , outputCSV )
@@ -216,7 +213,7 @@ func TestGoCSVNew(t *testing.T) {
216
213
217
214
outputCSV , err := generateCSV (b )
218
215
if err != nil {
219
- t .Errorf ("error occurred %v" , err )
216
+ t .Errorf ("Error occurred while generating CSV %v" , err )
220
217
}
221
218
removeSDKstampsFromCSVHelper (outputCSV )
222
219
assert .Equal (t , expCSV , outputCSV )
@@ -253,7 +250,7 @@ func TestGoCSVUpdate(t *testing.T) {
253
250
254
251
outputCSV , err := generateCSV (b )
255
252
if err != nil {
256
- t .Errorf ("error occurred %v" , err )
253
+ t .Errorf ("Error occurred while generating CSV, %v" , err )
257
254
}
258
255
removeSDKstampsFromCSVHelper (outputCSV )
259
256
assert .Equal (t , expCSV , outputCSV )
@@ -290,7 +287,7 @@ func TestGoCSVUpgrade(t *testing.T) {
290
287
291
288
outputCSV , err := generateCSV (b )
292
289
if err != nil {
293
- t .Errorf ("error occurred %v" , err )
290
+ t .Errorf ("Error occurred while generating CSV, %v" , err )
294
291
}
295
292
removeSDKstampsFromCSVHelper (outputCSV )
296
293
assert .Equal (t , expCSV , outputCSV )
@@ -327,7 +324,7 @@ func TestGoCSVNewManifests(t *testing.T) {
327
324
expCSV := getCSVFromFile (t , filepath .Join (OLMCatalogDir , testProjectName , noUpdateDir , csvExpFile ))
328
325
outputCSV , err := generateCSV (b )
329
326
if err != nil {
330
- t .Errorf ("error occurred %v" , err )
327
+ t .Errorf ("Error occurred while generating CSV, %v" , err )
331
328
}
332
329
removeSDKstampsFromCSVHelper (outputCSV )
333
330
assert .Equal (t , expCSV , outputCSV )
@@ -362,12 +359,12 @@ func TestGoCSVUpdateManifests(t *testing.T) {
362
359
} else {
363
360
expCSV := getCSVFromFile (t , filepath .Join (OLMCatalogDir , testProjectName , csvVersion , csvExpFile ))
364
361
if err != nil {
365
- t .Errorf ("error occurred %v" , err )
362
+ t .Errorf ("Error occurred while generating CSV, %v" , err )
366
363
}
367
364
368
365
outputCSV , err := generateCSV (b )
369
366
if err != nil {
370
- t .Errorf ("error occurred %v" , err )
367
+ t .Errorf ("Error occurred while generating CSV, %v" , err )
371
368
}
372
369
removeSDKstampsFromCSVHelper (outputCSV )
373
370
assert .Equal (t , expCSV , outputCSV )
@@ -449,6 +446,31 @@ func TestGoCSVNewWithEmptyDeployDir(t *testing.T) {
449
446
}
450
447
}
451
448
449
+ func TestSDKStamps (t * testing.T ) {
450
+ cleanupFunc := chDirWithCleanup (t , testGoDataDir )
451
+ defer cleanupFunc ()
452
+
453
+ b := bases.ClusterServiceVersion {
454
+ OperatorName : testProjectName ,
455
+ OperatorType : projutil .OperatorTypeGo ,
456
+ }
457
+
458
+ // check if base CSV has the required stamp values
459
+ csv , err := b .GetBase ()
460
+ if err != nil {
461
+ t .Fatal (err )
462
+ }
463
+
464
+ annotations := csv .ObjectMeta .Annotations
465
+ if _ , ok := annotations [projutil .OperatorBuilder ]; ! ok {
466
+ t .Errorf ("CSV base does not contain SDK stamp %s" , projutil .OperatorBuilder )
467
+ }
468
+
469
+ if _ , ok := annotations [projutil .OperatorLayout ]; ! ok {
470
+ t .Errorf ("CSV base does not contain SDK stamp %s" , projutil .OperatorLayout )
471
+ }
472
+ }
473
+
452
474
func TestUpdateCSVVersion (t * testing.T ) {
453
475
cleanupFunc := chDirWithCleanup (t , testGoDataDir )
454
476
defer cleanupFunc ()
@@ -511,12 +533,12 @@ func getCSVFromFile(t *testing.T, path string) *olmapiv1alpha1.ClusterServiceVer
511
533
csvpath := filepath .Join (path )
512
534
b , err := ioutil .ReadFile (csvpath )
513
535
if err != nil {
514
- t .Errorf ("error reading manifest %s: %v" , path , err )
536
+ t .Errorf ("Error reading manifest %s: %v" , path , err )
515
537
}
516
538
517
539
csv , err := generateCSV (b )
518
540
if err != nil {
519
- t .Errorf ("error generating csv %s: %v" , path , err )
541
+ t .Errorf ("Error generating csv %s: %v" , path , err )
520
542
}
521
543
return csv
522
544
}
@@ -548,12 +570,10 @@ func generateCSV(input []byte) (*olmapiv1alpha1.ClusterServiceVersion, error) {
548
570
// removeSDKstampsFromCSV removes the sdk stamps from CSV struct. Used for test cases where
549
571
// we need to test the generated CSV with expected predefined CSV file on disk.
550
572
func removeSDKstampsFromCSVHelper (csv * v1alpha1.ClusterServiceVersion ) {
551
- if _ , exist := csv .ObjectMeta .Annotations [projutil .Builder ]; exist {
552
- metricLabels := projutil .MakeMetricsLabels ()
573
+ if _ , exist := csv .ObjectMeta .Annotations [projutil .OperatorBuilder ]; exist {
574
+ metricLabels := projutil .MakeOperatorMetricLables ()
553
575
for label := range metricLabels .Data {
554
- if label != projutil .Mediatype {
555
- delete (csv .ObjectMeta .Annotations , label )
556
- }
576
+ delete (csv .ObjectMeta .Annotations , label )
557
577
}
558
578
}
559
579
}
0 commit comments