Skip to content

Commit

Permalink
Merge pull request containers#7341 from edsantiago/e2e_use_tmpdirs
Browse files Browse the repository at this point in the history
e2e tests: use actual temp dirs, not "/tmp/dir"
  • Loading branch information
openshift-merge-robot committed Aug 18, 2020
2 parents 7995f85 + bc07e1b commit ff1f81b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
11 changes: 8 additions & 3 deletions test/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ var _ = Describe("Podman build", func() {
defer Expect(os.Chdir(cwd)).To(BeNil())

// Write target and fake files
targetPath := filepath.Join(os.TempDir(), "dir")
Expect(os.MkdirAll(targetPath, 0755)).To(BeNil())
targetPath, err := CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}

fakeFile := filepath.Join(os.TempDir(), "Containerfile")
Expect(ioutil.WriteFile(fakeFile, []byte("FROM alpine"), 0755)).To(BeNil())
Expand Down Expand Up @@ -162,7 +164,10 @@ var _ = Describe("Podman build", func() {
Expect(os.Chdir(os.TempDir())).To(BeNil())
defer Expect(os.Chdir(cwd)).To(BeNil())

targetPath := filepath.Join(os.TempDir(), "dir")
targetPath, err := CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
targetFile := filepath.Join(targetPath, "idFile")

session := podmanTest.PodmanNoCache([]string{"build", "build/basicalpine", "--iidfile", targetFile})
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@ var _ = Describe("Podman commit", func() {
cwd, err := os.Getwd()
Expect(err).To(BeNil())
Expect(os.Chdir(os.TempDir())).To(BeNil())
targetPath := filepath.Join(os.TempDir(), "dir")
Expect(os.MkdirAll(targetPath, 0755)).To(BeNil())
targetPath, err := CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
targetFile := filepath.Join(targetPath, "idFile")
defer Expect(os.RemoveAll(targetFile)).To(BeNil())
defer Expect(os.Chdir(cwd)).To(BeNil())
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/pod_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,10 @@ var _ = Describe("Podman pod create", func() {
cwd, err := os.Getwd()
Expect(err).To(BeNil())
Expect(os.Chdir(os.TempDir())).To(BeNil())
targetPath := filepath.Join(os.TempDir(), "dir")
Expect(os.MkdirAll(targetPath, 0755)).To(BeNil())
targetPath, err := CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
targetFile := filepath.Join(targetPath, "idFile")
defer Expect(os.RemoveAll(targetFile)).To(BeNil())
defer Expect(os.Chdir(cwd)).To(BeNil())
Expand Down

0 comments on commit ff1f81b

Please sign in to comment.