@@ -36,6 +36,9 @@ var _ = Describe("Test", func() {
3636 var s * runtime.Scheme
3737 var c client.Client
3838
39+ var validDirectory = filepath .Join ("." , "testdata" )
40+ var invalidDirectory = "fake"
41+
3942 // Initialize the client
4043 BeforeEach (func (done Done ) {
4144 crds = []* v1beta1.CustomResourceDefinition {}
@@ -71,7 +74,7 @@ var _ = Describe("Test", func() {
7174 Describe ("InstallCRDs" , func () {
7275 It ("should install the CRDs into the cluster using directory" , func (done Done ) {
7376 crds , err = InstallCRDs (env .Config , CRDInstallOptions {
74- Paths : []string {filepath . Join ( "." , "testdata" ) },
77+ Paths : []string {validDirectory },
7578 })
7679 Expect (err ).NotTo (HaveOccurred ())
7780
@@ -222,14 +225,16 @@ var _ = Describe("Test", func() {
222225 }, 10 )
223226
224227 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 }})
226229 Expect (err ).NotTo (HaveOccurred ())
227230
228231 close (done )
229232 }, 5 )
230233
231234 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+ })
233238 Expect (err ).To (HaveOccurred ())
234239
235240 close (done )
@@ -299,7 +304,7 @@ var _ = Describe("Test", func() {
299304 It ("should uninstall the CRDs from the cluster" , func (done Done ) {
300305
301306 crds , err = InstallCRDs (env .Config , CRDInstallOptions {
302- Paths : []string {filepath . Join ( "." , "testdata" ) },
307+ Paths : []string {validDirectory },
303308 })
304309 Expect (err ).NotTo (HaveOccurred ())
305310
@@ -388,7 +393,7 @@ var _ = Describe("Test", func() {
388393 Expect (err ).NotTo (HaveOccurred ())
389394
390395 err = UninstallCRDs (env .Config , CRDInstallOptions {
391- Paths : []string {filepath . Join ( "." , "testdata" ) },
396+ Paths : []string {validDirectory },
392397 })
393398 Expect (err ).NotTo (HaveOccurred ())
394399
@@ -416,4 +421,20 @@ var _ = Describe("Test", func() {
416421 close (done )
417422 }, 30 )
418423 })
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+ })
419440})
0 commit comments