diff --git a/core/cautils/fileutils_test.go b/core/cautils/fileutils_test.go index 076f79b1..69609187 100644 --- a/core/cautils/fileutils_test.go +++ b/core/cautils/fileutils_test.go @@ -12,12 +12,12 @@ import ( func onlineBoutiquePath() string { o, _ := os.Getwd() - return filepath.Join(filepath.Dir(o), "../examples/online-boutique/*") + return filepath.Join(filepath.Dir(o), "..", "examples", "online-boutique") } func helmChartPath() string { o, _ := os.Getwd() - return filepath.Join(filepath.Dir(o), "../examples/helm_chart/*") + return filepath.Join(filepath.Dir(o), "..", "examples", "helm_chart") } func TestListFiles(t *testing.T) { @@ -79,10 +79,10 @@ func TestLoadFiles(t *testing.T) { } func TestListDirs(t *testing.T) { - dirs, _ := listDirs(strings.Replace(onlineBoutiquePath(), "*", "adservice.yaml", 1)) + dirs, _ := listDirs(filepath.Join(onlineBoutiquePath(), "adservice.yaml")) assert.Equal(t, 0, len(dirs)) - expectedDirs := []string{"examples/helm_chart", "examples/helm_chart/templates"} + expectedDirs := []string{filepath.Join("examples", "helm_chart"), filepath.Join("examples", "helm_chart", "templates")} dirs, _ = listDirs(helmChartPath()) assert.Equal(t, len(expectedDirs), len(dirs)) for i := range expectedDirs { @@ -91,7 +91,7 @@ func TestListDirs(t *testing.T) { } func TestLoadFile(t *testing.T) { - files, _ := listFiles(strings.Replace(onlineBoutiquePath(), "*", "adservice.yaml", 1)) + files, _ := listFiles(filepath.Join(onlineBoutiquePath(), "adservice.yaml")) assert.Equal(t, 1, len(files)) _, err := loadFile(files[0]) diff --git a/core/cautils/helmchart_test.go b/core/cautils/helmchart_test.go index dc385a06..5fa4b2c4 100644 --- a/core/cautils/helmchart_test.go +++ b/core/cautils/helmchart_test.go @@ -27,19 +27,19 @@ func TestHelmChartTestSuite(t *testing.T) { func (s *HelmChartTestSuite) SetupSuite() { o, _ := os.Getwd() - s.helmChartPath = filepath.Join(filepath.Dir(o), "../examples/helm_chart") + s.helmChartPath = filepath.Join(filepath.Dir(o), "..", "examples", "helm_chart") s.expectedFiles = []string{ - filepath.Join(s.helmChartPath, "templates/clusterrolebinding.yaml"), - filepath.Join(s.helmChartPath, "templates/clusterrole.yaml"), - filepath.Join(s.helmChartPath, "templates/serviceaccount.yaml"), - filepath.Join(s.helmChartPath, "templates/rolebinding.yaml"), - filepath.Join(s.helmChartPath, "templates/role.yaml"), - filepath.Join(s.helmChartPath, "templates/cronjob.yaml"), + filepath.Join(s.helmChartPath, "templates", "clusterrolebinding.yaml"), + filepath.Join(s.helmChartPath, "templates", "clusterrole.yaml"), + filepath.Join(s.helmChartPath, "templates", "serviceaccount.yaml"), + filepath.Join(s.helmChartPath, "templates", "rolebinding.yaml"), + filepath.Join(s.helmChartPath, "templates", "role.yaml"), + filepath.Join(s.helmChartPath, "templates", "cronjob.yaml"), } var obj interface{} - file, _ := ioutil.ReadFile("testdata/helm_expected_default_values.json") + file, _ := ioutil.ReadFile(filepath.Join("testdata", "helm_expected_default_values.json")) _ = json.Unmarshal([]byte(file), &obj) s.expectedDefaultValues = obj.(map[string]interface{}) } diff --git a/core/cautils/localgitrepository_test.go b/core/cautils/localgitrepository_test.go index bb713639..1ce827d2 100644 --- a/core/cautils/localgitrepository_test.go +++ b/core/cautils/localgitrepository_test.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "os" - "path" "path/filepath" "strings" "testing" @@ -62,9 +61,9 @@ func unzipFile(zipPath, destinationFolder string) (*zip.ReadCloser, error) { } func (s *LocalGitRepositoryTestSuite) SetupSuite() { - zippedFixturePath := path.Join(".", "testdata", "localrepo.git") - destinationPath := path.Join(".", "testdata", "temp") - gitRepositoryPath := path.Join(destinationPath, "localrepo") + zippedFixturePath := filepath.Join(".", "testdata", "localrepo.git") + destinationPath := filepath.Join(".", "testdata", "temp") + gitRepositoryPath := filepath.Join(destinationPath, "localrepo") os.RemoveAll(destinationPath) archive, err := unzipFile(zippedFixturePath, destinationPath)