diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2022-07-07 15:17:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 15:17:40 +0000 |
commit | dd0418a5fe0c44d4358b0118bd2a9847d78a80a2 (patch) | |
tree | 16878580c5e99c505a1b339e6fb270c07d5eb79a /pkg/machine/e2e/info_test.go | |
parent | 1855b63e5acc4d96dcbb0c4269b8c40498cdd000 (diff) | |
parent | 9d6efb34428811cc2b55b306733911cf20bd0b44 (diff) | |
download | podman-dd0418a5fe0c44d4358b0118bd2a9847d78a80a2.tar.gz podman-dd0418a5fe0c44d4358b0118bd2a9847d78a80a2.tar.bz2 podman-dd0418a5fe0c44d4358b0118bd2a9847d78a80a2.zip |
Merge pull request #14762 from ashley-cui/machinfo
Podman machine info
Diffstat (limited to 'pkg/machine/e2e/info_test.go')
-rw-r--r-- | pkg/machine/e2e/info_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/pkg/machine/e2e/info_test.go b/pkg/machine/e2e/info_test.go new file mode 100644 index 000000000..eeabb78af --- /dev/null +++ b/pkg/machine/e2e/info_test.go @@ -0,0 +1,58 @@ +package e2e + +import ( + "github.com/containers/podman/v4/cmd/podman/machine" + jsoniter "github.com/json-iterator/go" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gexec" +) + +var _ = Describe("podman machine info", func() { + var ( + mb *machineTestBuilder + testDir string + ) + + BeforeEach(func() { + testDir, mb = setup() + }) + AfterEach(func() { + teardown(originalHomeDir, testDir, mb) + }) + + 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 no running 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")) + + // Create a machine and check if info has been updated + i := new(initMachine) + initSession, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() + Expect(err).To(BeNil()) + 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("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 := &machine.Info{} + err = jsoniter.Unmarshal(infoSession.Bytes(), infoReport) + Expect(err).To(BeNil()) + }) +}) |