diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-07-15 10:37:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-15 10:37:11 -0400 |
commit | bc98c2003d36f9ce5650c1e0f4445be97ca0fa18 (patch) | |
tree | 9c3a777a89c015266578b7349a0f1233c2f325d0 /test/e2e/top_test.go | |
parent | 47f351769bbf9e06ec47d340943e5a494d586e79 (diff) | |
parent | 547fff27033a294d1639ee3f9125f775032f39f5 (diff) | |
download | podman-bc98c2003d36f9ce5650c1e0f4445be97ca0fa18.tar.gz podman-bc98c2003d36f9ce5650c1e0f4445be97ca0fa18.tar.bz2 podman-bc98c2003d36f9ce5650c1e0f4445be97ca0fa18.zip |
Merge pull request #10932 from edsantiago/e2e_exit_checks
e2e tests: use Should(Exit()) and ExitWithError()
Diffstat (limited to 'test/e2e/top_test.go')
-rw-r--r-- | test/e2e/top_test.go | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index d7105b17a..3cf6244b6 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -6,6 +6,7 @@ import ( . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gexec" ) var _ = Describe("Podman top", func() { @@ -35,13 +36,13 @@ var _ = Describe("Podman top", func() { It("podman top without container name or id", func() { result := podmanTest.Podman([]string{"top"}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(125)) + Expect(result).Should(Exit(125)) }) It("podman top on bogus container", func() { result := podmanTest.Podman([]string{"top", "1234"}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(125)) + Expect(result).Should(Exit(125)) }) It("podman top on non-running container", func() { @@ -49,68 +50,68 @@ var _ = Describe("Podman top", func() { Expect(ec).To(Equal(0)) result := podmanTest.Podman([]string{"top", cid}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(125)) + Expect(result).Should(Exit(125)) }) It("podman top on container", func() { session := podmanTest.Podman([]string{"run", "--name", "test", "-d", ALPINE, "top", "-d", "2"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) result := podmanTest.Podman([]string{"top", "test"}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(0)) + Expect(result).Should(Exit(0)) Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) It("podman container top on container", func() { session := podmanTest.Podman([]string{"container", "run", "--name", "test", "-d", ALPINE, "top", "-d", "2"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) result := podmanTest.Podman([]string{"container", "top", "test"}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(0)) + Expect(result).Should(Exit(0)) Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) It("podman top with options", func() { session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top", "-d", "2"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) result := podmanTest.Podman([]string{"top", session.OutputToString(), "pid", "%C", "args"}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(0)) + Expect(result).Should(Exit(0)) Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) It("podman top with ps(1) options", func() { session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top", "-d", "2"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) result := podmanTest.Podman([]string{"top", session.OutputToString(), "aux"}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(0)) + Expect(result).Should(Exit(0)) Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) It("podman top with comma-separated options", func() { session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top", "-d", "2"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) result := podmanTest.Podman([]string{"top", session.OutputToString(), "user,pid,comm"}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(0)) + Expect(result).Should(Exit(0)) Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) It("podman top on container invalid options", func() { top := podmanTest.RunTopContainer("") top.WaitWithDefaultTimeout() - Expect(top.ExitCode()).To(Equal(0)) + Expect(top).Should(Exit(0)) cid := top.OutputToString() // We need to pass -eo to force executing ps in the Alpine container. @@ -119,7 +120,7 @@ var _ = Describe("Podman top", func() { // the wrong input and still print the -ef output instead. result := podmanTest.Podman([]string{"top", cid, "-eo", "invalid"}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(125)) + Expect(result).Should(Exit(125)) }) }) |