Stop using rm'd inspect format templates in tests

Fixes the "machine rm --save-ignition --save-image" test so that it no longer
uses the `{{ .Image }}` format string.

Fixes the "init should cleanup on failure" test so that it no longer
uses the `{{ .Image }}` and `{{ .ConfigPath }}` format strings.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
This commit is contained in:
Jake Correnti
2024-02-06 12:40:37 -05:00
parent be9aba7ccd
commit d7f7f07c9b
2 changed files with 10 additions and 25 deletions

View File

@ -287,16 +287,6 @@ var _ = Describe("podman machine init", func() {
Expect(err).ToNot(HaveOccurred())
cfgpth := filepath.Join(inspectSession.outputToString(), fmt.Sprintf("%s.json", name))
inspect = inspect.withFormat("{{.Image.IgnitionFile.Path}}")
inspectSession, err = mb.setCmd(inspect).run()
Expect(err).ToNot(HaveOccurred())
ign := inspectSession.outputToString()
inspect = inspect.withFormat("{{.Image.ImagePath.Path}}")
inspectSession, err = mb.setCmd(inspect).run()
Expect(err).ToNot(HaveOccurred())
img := inspectSession.outputToString()
rm := rmMachine{}
removeSession, err := mb.setCmd(rm.withForce()).run()
Expect(err).ToNot(HaveOccurred())
@ -317,13 +307,17 @@ var _ = Describe("podman machine init", func() {
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(125))
// ensure files created by init are cleaned up on init failure
_, err = os.Stat(img)
imageSuffix := mb.imagePath[strings.LastIndex(mb.imagePath, "/")+1:]
imgPath := filepath.Join(testDir, ".local", "share", "containers", "podman", "machine", "qemu", mb.name+"_"+imageSuffix)
_, err = os.Stat(imgPath)
Expect(err).To(HaveOccurred())
cfgDir := filepath.Join(testDir, ".config", "containers", "podman", "machine", testProvider.VMType().String())
_, err = os.Stat(cfgpth)
Expect(err).To(HaveOccurred())
_, err = os.Stat(ign)
ignPath := filepath.Join(cfgDir, mb.name+".ign")
_, err = os.Stat(ignPath)
Expect(err).To(HaveOccurred())
}
})

View File

@ -94,16 +94,6 @@ var _ = Describe("podman machine rm", func() {
key := inspectSession.outputToString()
pubkey := key + ".pub"
inspect = inspect.withFormat("{{.Image.IgnitionFile.Path}}")
inspectSession, err = mb.setCmd(inspect).run()
Expect(err).ToNot(HaveOccurred())
ign := inspectSession.outputToString()
inspect = inspect.withFormat("{{.Image.ImagePath.Path}}")
inspectSession, err = mb.setCmd(inspect).run()
Expect(err).ToNot(HaveOccurred())
img := inspectSession.outputToString()
rm := rmMachine{}
removeSession, err := mb.setCmd(rm.withForce().withSaveIgnition().withSaveImage()).run()
Expect(err).ToNot(HaveOccurred())
@ -122,10 +112,11 @@ var _ = Describe("podman machine rm", func() {
// WSL does not use ignition
if testProvider.VMType() != define.WSLVirt {
_, err = os.Stat(ign)
ignPath := filepath.Join(testDir, ".config", "containers", "podman", "machine", testProvider.VMType().String(), mb.name+".ign")
_, err = os.Stat(ignPath)
Expect(err).ToNot(HaveOccurred())
}
_, err = os.Stat(img)
_, err = os.Stat(mb.imagePath)
Expect(err).ToNot(HaveOccurred())
})