ephemeral-disk_test: shorten with GinkgoT.TempDir()
Replacing explicit TempDir creation makes the test shorter, and also
makes it harder to forget directory cleanup or needlessly define
backingTempDirPath.
@@ -21,7 +21,6 @@ package ephemeraldisk
import (
"fmt"
- "io/ioutil"
"os"
"path/filepath"
@@ -37,7 +36,6 @@ import (
var _ = Describe("ContainerDisk", func() {
var imageTempDirPath string
- var backingTempDirPath string
var pvcBaseTempDirPath string
var blockDevBaseDir string
var creator *ephemeralDiskCreator
@@ -80,19 +78,9 @@ var _ = Describe("ContainerDisk", func() {
}
BeforeEach(func() {
- var err error
-
- backingTempDirPath, err = ioutil.TempDir("", "ephemeraldisk-backing")
- Expect(err).NotTo(HaveOccurred())
-
- imageTempDirPath, err = ioutil.TempDir("", "ephemeraldisk-image")
- Expect(err).NotTo(HaveOccurred())
-
- pvcBaseTempDirPath, err = ioutil.TempDir("", "pvc-base-dir-path")
- Expect(err).NotTo(HaveOccurred())
-
- blockDevBaseDir, err = ioutil.TempDir("", "block-dev-base-dir-path")
- Expect(err).NotTo(HaveOccurred())
+ imageTempDirPath = GinkgoT().TempDir()
+ pvcBaseTempDirPath = GinkgoT().TempDir()
+ blockDevBaseDir = GinkgoT().TempDir()
creator = &ephemeralDiskCreator{
mountBaseDir: imageTempDirPath,
@@ -102,12 +90,6 @@ var _ = Describe("ContainerDisk", func() {
}
})
- AfterEach(func() {
- os.RemoveAll(imageTempDirPath)
- os.RemoveAll(backingTempDirPath)
- os.RemoveAll(pvcBaseTempDirPath)
- })
-
Describe("ephemeral-backed PVC", func() {
Context("With single ephemeral volume", func() {
It("Should create VirtualMachineInstance's ephemeral image", func() {
