1
1
package convert_test
2
2
3
3
import (
4
+ "errors"
4
5
"fmt"
5
6
"io/fs"
6
7
"os"
@@ -52,6 +53,24 @@ func getCsvAndService() (v1alpha1.ClusterServiceVersion, corev1.Service) {
52
53
return csv , svc
53
54
}
54
55
56
+ func TestConverterValidatesBundle (t * testing.T ) {
57
+ converter := convert.Converter {
58
+ BundleValidator : []func (rv1 * convert.RegistryV1 ) []error {
59
+ func (rv1 * convert.RegistryV1 ) []error {
60
+ return []error {errors .New ("test error" )}
61
+ },
62
+ },
63
+ }
64
+
65
+ _ , err := converter .Convert (convert.RegistryV1 {}, "installNamespace" , []string {"watchNamespace" })
66
+ require .Error (t , err )
67
+ require .Contains (t , err .Error (), "test error" )
68
+ }
69
+
70
+ func TestPlainConverterUsedRegV1Validator (t * testing.T ) {
71
+ require .Equal (t , convert .RegistryV1BundleValidator , convert .PlainConverter .BundleValidator )
72
+ }
73
+
55
74
func TestRegistryV1SuiteNamespaceNotAvailable (t * testing.T ) {
56
75
var targetNamespaces []string
57
76
@@ -70,7 +89,7 @@ func TestRegistryV1SuiteNamespaceNotAvailable(t *testing.T) {
70
89
}
71
90
72
91
t .Log ("By converting to plain" )
73
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , targetNamespaces )
92
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , targetNamespaces )
74
93
require .NoError (t , err )
75
94
76
95
t .Log ("By verifying if plain bundle has required objects" )
@@ -104,7 +123,7 @@ func TestRegistryV1SuiteNamespaceAvailable(t *testing.T) {
104
123
}
105
124
106
125
t .Log ("By converting to plain" )
107
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , targetNamespaces )
126
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , targetNamespaces )
108
127
require .NoError (t , err )
109
128
110
129
t .Log ("By verifying if plain bundle has required objects" )
@@ -145,7 +164,7 @@ func TestRegistryV1SuiteNamespaceUnsupportedKind(t *testing.T) {
145
164
}
146
165
147
166
t .Log ("By converting to plain" )
148
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , targetNamespaces )
167
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , targetNamespaces )
149
168
require .Error (t , err )
150
169
require .ErrorContains (t , err , "bundle contains unsupported resource" )
151
170
require .Nil (t , plainBundle )
@@ -179,7 +198,7 @@ func TestRegistryV1SuiteNamespaceClusterScoped(t *testing.T) {
179
198
}
180
199
181
200
t .Log ("By converting to plain" )
182
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , targetNamespaces )
201
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , targetNamespaces )
183
202
require .NoError (t , err )
184
203
185
204
t .Log ("By verifying if plain bundle has required objects" )
@@ -266,7 +285,7 @@ func TestRegistryV1SuiteGenerateAllNamespace(t *testing.T) {
266
285
}
267
286
268
287
t .Log ("By converting to plain" )
269
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , watchNamespaces )
288
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , watchNamespaces )
270
289
require .NoError (t , err )
271
290
272
291
t .Log ("By verifying if plain bundle has required objects" )
@@ -299,7 +318,7 @@ func TestRegistryV1SuiteGenerateMultiNamespace(t *testing.T) {
299
318
}
300
319
301
320
t .Log ("By converting to plain" )
302
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , watchNamespaces )
321
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , watchNamespaces )
303
322
require .NoError (t , err )
304
323
305
324
t .Log ("By verifying if plain bundle has required objects" )
@@ -332,7 +351,7 @@ func TestRegistryV1SuiteGenerateSingleNamespace(t *testing.T) {
332
351
}
333
352
334
353
t .Log ("By converting to plain" )
335
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , watchNamespaces )
354
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , watchNamespaces )
336
355
require .NoError (t , err )
337
356
338
357
t .Log ("By verifying if plain bundle has required objects" )
@@ -365,7 +384,7 @@ func TestRegistryV1SuiteGenerateOwnNamespace(t *testing.T) {
365
384
}
366
385
367
386
t .Log ("By converting to plain" )
368
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , watchNamespaces )
387
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , watchNamespaces )
369
388
require .NoError (t , err )
370
389
371
390
t .Log ("By verifying if plain bundle has required objects" )
@@ -470,7 +489,7 @@ func TestConvertInstallModeValidation(t *testing.T) {
470
489
}
471
490
472
491
t .Log ("By converting to plain" )
473
- plainBundle , err := convert .Convert (registryv1Bundle , tc .installNamespace , tc .watchNamespaces )
492
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , tc .installNamespace , tc .watchNamespaces )
474
493
require .Error (t , err )
475
494
require .Nil (t , plainBundle )
476
495
})
@@ -559,7 +578,7 @@ func TestRegistryV1SuiteGenerateNoWebhooks(t *testing.T) {
559
578
}
560
579
561
580
t .Log ("By converting to plain" )
562
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , watchNamespaces )
581
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , watchNamespaces )
563
582
require .Error (t , err )
564
583
require .ErrorContains (t , err , "webhookDefinitions are not supported" )
565
584
require .Nil (t , plainBundle )
@@ -590,7 +609,7 @@ func TestRegistryV1SuiteGenerateNoAPISerciceDefinitions(t *testing.T) {
590
609
}
591
610
592
611
t .Log ("By converting to plain" )
593
- plainBundle , err := convert .Convert (registryv1Bundle , installNamespace , watchNamespaces )
612
+ plainBundle , err := convert .PlainConverter . Convert (registryv1Bundle , installNamespace , watchNamespaces )
594
613
require .Error (t , err )
595
614
require .ErrorContains (t , err , "apiServiceDefintions are not supported" )
596
615
require .Nil (t , plainBundle )
0 commit comments