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:
Paul Holzinger
2023-04-17 12:16:20 +02:00
parent 601d228cae
commit 1f45c715df
10 changed files with 34 additions and 74 deletions

View File

@ -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")