From 80952db0ba7063e557c49146fd2d738c929f9885 Mon Sep 17 00:00:00 2001 From: Ashley Cui Date: Fri, 22 Sep 2023 14:50:25 -0400 Subject: [PATCH] Fix podman machine info test for hyperV We do not guarantee that the amount of machines that exist on the system is 0 before running a test. Signed-off-by: Ashley Cui --- pkg/machine/e2e/info_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/machine/e2e/info_test.go b/pkg/machine/e2e/info_test.go index def9defbd7..b016e3e1e1 100644 --- a/pkg/machine/e2e/info_test.go +++ b/pkg/machine/e2e/info_test.go @@ -1,6 +1,8 @@ package e2e_test import ( + "strconv" + "github.com/containers/podman/v4/pkg/domain/entities" jsoniter "github.com/json-iterator/go" . "github.com/onsi/ginkgo/v2" @@ -27,12 +29,13 @@ var _ = Describe("podman machine info", func() { Expect(err).NotTo(HaveOccurred()) Expect(infoSession).Should(Exit(0)) - // Verify go template works and check for no running machines + // 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)) - Expect(infoSession.outputToString()).To(Equal("0")) + numMachines, err := strconv.Atoi(infoSession.outputToString()) + Expect(err).ToNot(HaveOccurred()) // Create a machine and check if info has been updated i := new(initMachine) @@ -44,7 +47,7 @@ var _ = Describe("podman machine info", func() { infoSession, err = mb.setCmd(info.withFormat("{{.Host.NumberOfMachines}}")).run() Expect(err).NotTo(HaveOccurred()) Expect(infoSession).Should(Exit(0)) - Expect(infoSession.outputToString()).To(Equal("1")) + Expect(infoSession.outputToString()).To(Equal(strconv.Itoa(numMachines + 1))) // Check if json is in correct format infoSession, err = mb.setCmd(info.withFormat("json")).run()