Files
podman/pkg/machine/e2e/info_test.go
Brent Baude 9cbb64c525 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>
2025-11-10 10:51:23 -06:00

51 lines
1.6 KiB
Go

package e2e_test
import (
"strconv"
"github.com/containers/podman/v6/pkg/domain/entities"
jsoniter "github.com/json-iterator/go"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("podman machine info", func() {
It("machine info", func() {
info := new(infoMachine)
infoSession, err := mb.setCmd(info).run()
Expect(err).NotTo(HaveOccurred())
Expect(infoSession).Should(Exit(0))
// Verify go template works and check for number of machines
info = new(infoMachine)
infoSession, err = mb.setCmd(info.withFormat("{{.Host.NumberOfMachines}}")).run()
Expect(err).NotTo(HaveOccurred())
Expect(infoSession).Should(Exit(0))
numMachines, err := strconv.Atoi(infoSession.outputToString())
Expect(err).ToNot(HaveOccurred())
// Create a machine and check if info has been updated
i := new(initMachine)
initSession, err := mb.setCmd(i.withFakeImage(mb)).run()
Expect(err).ToNot(HaveOccurred())
Expect(initSession).To(Exit(0))
info = new(infoMachine)
infoSession, err = mb.setCmd(info.withFormat("{{.Host.NumberOfMachines}}")).run()
Expect(err).NotTo(HaveOccurred())
Expect(infoSession).Should(Exit(0))
Expect(infoSession.outputToString()).To(Equal(strconv.Itoa(numMachines + 1)))
// Check if json is in correct format
infoSession, err = mb.setCmd(info.withFormat("json")).run()
Expect(err).NotTo(HaveOccurred())
Expect(infoSession).Should(Exit(0))
infoReport := &entities.MachineInfo{}
err = jsoniter.Unmarshal(infoSession.Bytes(), infoReport)
Expect(err).ToNot(HaveOccurred())
})
})