Skip to content

Commit

Permalink
Make sure tests are cleaned up when they complete
Browse files Browse the repository at this point in the history
Fixes: containers#13789

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed May 12, 2022
1 parent 8631485 commit b810364
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
13 changes: 7 additions & 6 deletions test/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,17 +786,18 @@ RUN ls /dev/test1`, ALPINE)

It("podman build use absolute path even if given relative", func() {
containerFile := fmt.Sprintf(`FROM %s`, ALPINE)
err = os.Mkdir("relative", 0755)
relativeDir := filepath.Join(podmanTest.TempDir, "relativeDir")
containerFilePath := filepath.Join(relativeDir, "Containerfile")
buildRoot := filepath.Join(relativeDir, "build-root")

err = os.Mkdir(relativeDir, 0755)
Expect(err).To(BeNil())
containerFilePath := filepath.Join("relative", "Containerfile")
err = os.Mkdir("relative/build-root", 0755)
err = os.Mkdir(buildRoot, 0755)
Expect(err).To(BeNil())
err = ioutil.WriteFile(containerFilePath, []byte(containerFile), 0755)
Expect(err).To(BeNil())
build := podmanTest.Podman([]string{"build", "-f", "./relative/Containerfile", "./relative/build-root"})
build := podmanTest.Podman([]string{"build", "-f", containerFilePath, buildRoot})
build.WaitWithDefaultTimeout()
Expect(build).To(Exit(0))
err = os.RemoveAll("relative")
Expect(err).To(BeNil())
})
})
5 changes: 3 additions & 2 deletions test/e2e/save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,13 @@ var _ = Describe("Podman save", func() {
err = cmd.Run()
Expect(err).To(BeNil())

cmd = exec.Command("cp", "/etc/containers/registries.d/default.yaml", "default.yaml")
defaultYaml := filepath.Join(podmanTest.TempDir, "default.yaml")
cmd = exec.Command("cp", "/etc/containers/registries.d/default.yaml", defaultYaml)
if err = cmd.Run(); err != nil {
Skip("no signature store to verify")
}
defer func() {
cmd = exec.Command("cp", "default.yaml", "/etc/containers/registries.d/default.yaml")
cmd = exec.Command("cp", defaultYaml, "/etc/containers/registries.d/default.yaml")
err := cmd.Run()
Expect(err).ToNot(HaveOccurred())
}()
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/volume_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package integration
import (
"fmt"
"os"
"path/filepath"

. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -90,15 +91,16 @@ var _ = Describe("Podman volume create", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

session = podmanTest.Podman([]string{"volume", "export", volName, "--output=hello.tar"})
helloTar := filepath.Join(podmanTest.TempDir, "hello.tar")
session = podmanTest.Podman([]string{"volume", "export", volName, "--output", helloTar})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

session = podmanTest.Podman([]string{"volume", "create", "my_vol2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

session = podmanTest.Podman([]string{"volume", "import", "my_vol2", "hello.tar"})
session = podmanTest.Podman([]string{"volume", "import", "my_vol2", helloTar})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(Equal(""), "output of volume import")
Expand Down

0 comments on commit b810364

Please sign in to comment.