Skip to content

Commit

Permalink
Use filepath instead of path in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colincasey committed Aug 4, 2023
1 parent 541852d commit 5a51f84
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions pkg/client/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"io"
"net/http"
"os"
"path"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -991,11 +990,11 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {

when("meta-buildpack folder is used", func() {
it("resolves buildpack", func() {
metaBuildpackFolder := path.Join(tmpDir, "meta-buildpack")
metaBuildpackFolder := filepath.Join(tmpDir, "meta-buildpack")
err := os.Mkdir(metaBuildpackFolder, os.ModePerm)
h.AssertNil(t, err)

err = os.WriteFile(path.Join(metaBuildpackFolder, "buildpack.toml"), []byte(`
err = os.WriteFile(filepath.Join(metaBuildpackFolder, "buildpack.toml"), []byte(`
api = "0.2"
[buildpack]
Expand All @@ -1010,7 +1009,7 @@ version = "local-meta-bp-version"
`), 0644)
h.AssertNil(t, err)

err = os.WriteFile(path.Join(metaBuildpackFolder, "package.toml"), []byte(`
err = os.WriteFile(filepath.Join(metaBuildpackFolder, "package.toml"), []byte(`
[buildpack]
uri = "."
Expand All @@ -1019,11 +1018,11 @@ uri = "../meta-buildpack-dependency"
`), 0644)
h.AssertNil(t, err)

metaBuildpackDependencyFolder := path.Join(tmpDir, "meta-buildpack-dependency")
metaBuildpackDependencyFolder := filepath.Join(tmpDir, "meta-buildpack-dependency")
err = os.Mkdir(metaBuildpackDependencyFolder, os.ModePerm)
h.AssertNil(t, err)

err = os.WriteFile(path.Join(metaBuildpackDependencyFolder, "buildpack.toml"), []byte(`
err = os.WriteFile(filepath.Join(metaBuildpackDependencyFolder, "buildpack.toml"), []byte(`
api = "0.2"
[buildpack]
Expand Down Expand Up @@ -1062,11 +1061,11 @@ api = "0.2"
})

it("fails if buildpack dependency could not be fetched", func() {
metaBuildpackFolder := path.Join(tmpDir, "meta-buildpack")
metaBuildpackFolder := filepath.Join(tmpDir, "meta-buildpack")
err := os.Mkdir(metaBuildpackFolder, os.ModePerm)
h.AssertNil(t, err)

err = os.WriteFile(path.Join(metaBuildpackFolder, "buildpack.toml"), []byte(`
err = os.WriteFile(filepath.Join(metaBuildpackFolder, "buildpack.toml"), []byte(`
api = "0.2"
[buildpack]
Expand All @@ -1081,7 +1080,7 @@ version = "local-meta-bp-version"
`), 0644)
h.AssertNil(t, err)

err = os.WriteFile(path.Join(metaBuildpackFolder, "package.toml"), []byte(`
err = os.WriteFile(filepath.Join(metaBuildpackFolder, "package.toml"), []byte(`
[buildpack]
uri = "."
Expand All @@ -1093,11 +1092,11 @@ uri = "../not-a-valid-dependency"
`), 0644)
h.AssertNil(t, err)

metaBuildpackDependencyFolder := path.Join(tmpDir, "meta-buildpack-dependency")
metaBuildpackDependencyFolder := filepath.Join(tmpDir, "meta-buildpack-dependency")
err = os.Mkdir(metaBuildpackDependencyFolder, os.ModePerm)
h.AssertNil(t, err)

err = os.WriteFile(path.Join(metaBuildpackDependencyFolder, "buildpack.toml"), []byte(`
err = os.WriteFile(filepath.Join(metaBuildpackDependencyFolder, "buildpack.toml"), []byte(`
api = "0.2"
[buildpack]
Expand All @@ -1116,7 +1115,7 @@ api = "0.2"
ClearCache: true,
Buildpacks: []string{metaBuildpackFolder},
})
h.AssertError(t, err, fmt.Sprintf("fetching package.toml dependencies (path='%s')", path.Join(metaBuildpackFolder, "package.toml")))
h.AssertError(t, err, fmt.Sprintf("fetching package.toml dependencies (path='%s')", filepath.Join(metaBuildpackFolder, "package.toml")))
h.AssertError(t, err, "fetching dependencies (uri='../not-a-valid-dependency',image='')")
})
})
Expand Down

0 comments on commit 5a51f84

Please sign in to comment.