Use fake images for machine tests

In tests that do not start a machine, we can use "fake" images to speed
up tests.  In the case of darwin and Linux, that can be /dev/null.  The
hypervisors don't care.

In the case of Windows, some research will need to be done to determine
the same approach but this is a start.

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude
2025-11-07 11:01:19 -06:00
parent 2c40377dc9
commit 9cbb64c525
14 changed files with 75 additions and 37 deletions

View File

@@ -22,7 +22,7 @@ var _ = Describe("podman machine init - windows only", func() {
}
i := new(initMachine)
name := randomString()
session, err := mb.setName(name).setCmd(i.withImage(mb.imagePath).withUserModeNetworking(true)).run()
session, err := mb.setName(name).setCmd(i.withFakeImage(mb).withUserModeNetworking(true)).run()
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))
@@ -79,7 +79,7 @@ var _ = Describe("podman machine init - windows only", func() {
}
}()
i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImage(mb.imagePath)).run()
session, err := mb.setName(name).setCmd(i.withFakeImage(mb)).run()
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(125))
Expect(session.errorToString()).To(ContainSubstring("already exists on hypervisor"))
@@ -97,7 +97,7 @@ var _ = Describe("podman machine init - windows only", func() {
// create a bogus machine
i := new(initMachine)
session, err := mb.setName("foobarexport").setCmd(i.withImage(mb.imagePath)).run()
session, err := mb.setName("foobarexport").setCmd(i.withFakeImage(mb)).run()
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))
@@ -122,7 +122,7 @@ var _ = Describe("podman machine init - windows only", func() {
}()
// Trying to make a vm with the same name as an existing name should result in a 125
checkSession, err := mb.setName(name).setCmd(i.withImage(mb.imagePath)).run()
checkSession, err := mb.setName(name).setCmd(i.withFakeImage(mb)).run()
Expect(err).ToNot(HaveOccurred())
Expect(checkSession).To(Exit(125))
})