@@ -36,6 +36,9 @@ var _ = Describe("Test", func() {
36
36
var s * runtime.Scheme
37
37
var c client.Client
38
38
39
+ var validDirectory = filepath .Join ("." , "testdata" )
40
+ var invalidDirectory = "fake"
41
+
39
42
// Initialize the client
40
43
BeforeEach (func (done Done ) {
41
44
crds = []* v1beta1.CustomResourceDefinition {}
@@ -71,7 +74,7 @@ var _ = Describe("Test", func() {
71
74
Describe ("InstallCRDs" , func () {
72
75
It ("should install the CRDs into the cluster using directory" , func (done Done ) {
73
76
crds , err = InstallCRDs (env .Config , CRDInstallOptions {
74
- Paths : []string {filepath . Join ( "." , "testdata" ) },
77
+ Paths : []string {validDirectory },
75
78
})
76
79
Expect (err ).NotTo (HaveOccurred ())
77
80
@@ -222,14 +225,16 @@ var _ = Describe("Test", func() {
222
225
}, 10 )
223
226
224
227
It ("should not return an not error if the directory doesn't exist" , func (done Done ) {
225
- crds , err = InstallCRDs (env .Config , CRDInstallOptions {Paths : []string {"fake" }})
228
+ crds , err = InstallCRDs (env .Config , CRDInstallOptions {Paths : []string {invalidDirectory }})
226
229
Expect (err ).NotTo (HaveOccurred ())
227
230
228
231
close (done )
229
232
}, 5 )
230
233
231
234
It ("should return an error if the directory doesn't exist" , func (done Done ) {
232
- crds , err = InstallCRDs (env .Config , CRDInstallOptions {Paths : []string {"fake" }, ErrorIfPathMissing : true })
235
+ crds , err = InstallCRDs (env .Config , CRDInstallOptions {
236
+ Paths : []string {invalidDirectory }, ErrorIfPathMissing : true ,
237
+ })
233
238
Expect (err ).To (HaveOccurred ())
234
239
235
240
close (done )
@@ -299,7 +304,7 @@ var _ = Describe("Test", func() {
299
304
It ("should uninstall the CRDs from the cluster" , func (done Done ) {
300
305
301
306
crds , err = InstallCRDs (env .Config , CRDInstallOptions {
302
- Paths : []string {filepath . Join ( "." , "testdata" ) },
307
+ Paths : []string {validDirectory },
303
308
})
304
309
Expect (err ).NotTo (HaveOccurred ())
305
310
@@ -388,7 +393,7 @@ var _ = Describe("Test", func() {
388
393
Expect (err ).NotTo (HaveOccurred ())
389
394
390
395
err = UninstallCRDs (env .Config , CRDInstallOptions {
391
- Paths : []string {filepath . Join ( "." , "testdata" ) },
396
+ Paths : []string {validDirectory },
392
397
})
393
398
Expect (err ).NotTo (HaveOccurred ())
394
399
@@ -416,4 +421,20 @@ var _ = Describe("Test", func() {
416
421
close (done )
417
422
}, 30 )
418
423
})
424
+
425
+ Describe ("Start" , func () {
426
+ It ("should raise an error on invalid dir when flag is enabled" , func (done Done ) {
427
+ env = & Environment {ErrorIfCRDPathMissing : true , CRDDirectoryPaths : []string {invalidDirectory }}
428
+ _ , err := env .Start ()
429
+ Expect (err ).To (HaveOccurred ())
430
+ close (done )
431
+ }, 30 )
432
+
433
+ It ("should not raise an error on invalid dir when flag is disabled" , func (done Done ) {
434
+ env = & Environment {ErrorIfCRDPathMissing : false , CRDDirectoryPaths : []string {invalidDirectory }}
435
+ _ , err := env .Start ()
436
+ Expect (err ).NotTo (HaveOccurred ())
437
+ close (done )
438
+ }, 30 )
439
+ })
419
440
})
0 commit comments