mirror of
https://github.com/containers/podman.git
synced 2025-05-22 09:36:57 +08:00
test/e2e: fix incorrect usage of CreateTempDirInTempDir()
Creating a new diretory results in the test leaking it when it is not removed via a defer call. All tests have already access to `podmanTest.TempDir` which will be automatically removed in the `AfterEach()` block. While some test were fine other forgot the defer call. To keep the test consitent and prevent other from making the same mistake convert all users to `podmanTest.TempDir`. `CreateTempDirInTempDir()` is only used for the `podmanTest.Setup()` call. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -270,12 +270,8 @@ var _ = Describe("Podman commit", func() {
|
||||
cwd, err := os.Getwd()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(os.Chdir(os.TempDir())).To(Succeed())
|
||||
targetPath, err := CreateTempDirInTempDir()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
targetPath := podmanTest.TempDir
|
||||
targetFile := filepath.Join(targetPath, "idFile")
|
||||
defer Expect(os.RemoveAll(targetFile)).To(BeNil())
|
||||
defer Expect(os.Chdir(cwd)).To(BeNil())
|
||||
|
||||
_, ec, _ := podmanTest.RunLsContainer("test1")
|
||||
|
Reference in New Issue
Block a user