Skip to content

Commit

Permalink
Issue #859 Integration: run tests and keep .crc folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jsliacan authored and cfergeau committed Dec 16, 2019
1 parent c644ed7 commit d1b374c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions test/integration/crcsuite/crcsuite.go
Expand Up @@ -139,6 +139,7 @@ func FeatureContext(s *godog.Suite) {
err = RemoveCRCHome()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
})

Expand Down
22 changes: 15 additions & 7 deletions test/integration/crcsuite/util.go
Expand Up @@ -5,6 +5,7 @@ package crcsuite
import (
"fmt"
"os"
"path/filepath"

clicumber "github.com/code-ready/clicumber/testsuite"
)
Expand All @@ -22,14 +23,21 @@ func DeleteCRC() error {
// Remove CRC home folder ~/.crc
func RemoveCRCHome() error {

err := os.RemoveAll(CRCHome)
keepFile := filepath.Join(CRCHome, ".keep")

if err != nil {
fmt.Printf("Problem deleting CRC home folder %s.\n", CRCHome)
return err
}
_, err := os.Stat(keepFile)
if err != nil { // cannot get keepFile's status
err = os.RemoveAll(CRCHome)

fmt.Printf("Deleted CRC home folder %s.\n", CRCHome)
return nil
if err != nil {
fmt.Printf("Problem deleting CRC home folder %s.\n", CRCHome)
return err
}

fmt.Printf("Deleted CRC home folder %s.\n", CRCHome)
return nil

}
// keepFile exists
return fmt.Errorf("Folder %s not removed as per request: %s present.\n", CRCHome, keepFile)
}

0 comments on commit d1b374c

Please sign in to comment.