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/import_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/import_test.go')
-rw-r--r-- | test/e2e/import_test.go | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go index 1f1b23bd0..519a7290c 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -7,6 +7,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 import", func() { @@ -41,15 +42,15 @@ var _ = Describe("Podman import", func() { export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) export.WaitWithDefaultTimeout() - Expect(export.ExitCode()).To(Equal(0)) + Expect(export).Should(Exit(0)) importImage := podmanTest.Podman([]string{"import", outfile, "foobar.com/imported-image:latest"}) importImage.WaitWithDefaultTimeout() - Expect(importImage.ExitCode()).To(Equal(0)) + Expect(importImage).Should(Exit(0)) results := podmanTest.Podman([]string{"inspect", "--type", "image", "foobar.com/imported-image:latest"}) results.WaitWithDefaultTimeout() - Expect(results.ExitCode()).To(Equal(0)) + Expect(results).Should(Exit(0)) }) It("podman import without reference", func() { @@ -59,16 +60,16 @@ var _ = Describe("Podman import", func() { export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) export.WaitWithDefaultTimeout() - Expect(export.ExitCode()).To(Equal(0)) + Expect(export).Should(Exit(0)) importImage := podmanTest.Podman([]string{"import", outfile}) importImage.WaitWithDefaultTimeout() - Expect(importImage.ExitCode()).To(Equal(0)) + Expect(importImage).Should(Exit(0)) // tag the image which proves it is in R/W storage tag := podmanTest.Podman([]string{"tag", importImage.OutputToString(), "foo"}) tag.WaitWithDefaultTimeout() - Expect(tag.ExitCode()).To(BeZero()) + Expect(tag).Should(Exit(0)) }) It("podman import with message flag", func() { @@ -78,15 +79,15 @@ var _ = Describe("Podman import", func() { export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) export.WaitWithDefaultTimeout() - Expect(export.ExitCode()).To(Equal(0)) + Expect(export).Should(Exit(0)) importImage := podmanTest.Podman([]string{"import", "--message", "importing container test message", outfile, "imported-image"}) importImage.WaitWithDefaultTimeout() - Expect(importImage.ExitCode()).To(Equal(0)) + Expect(importImage).Should(Exit(0)) results := podmanTest.Podman([]string{"history", "imported-image", "--format", "{{.Comment}}"}) results.WaitWithDefaultTimeout() - Expect(results.ExitCode()).To(Equal(0)) + Expect(results).Should(Exit(0)) Expect(results.LineInOutputStartsWith("importing container test message")).To(BeTrue()) }) @@ -97,15 +98,15 @@ var _ = Describe("Podman import", func() { export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) export.WaitWithDefaultTimeout() - Expect(export.ExitCode()).To(Equal(0)) + Expect(export).Should(Exit(0)) importImage := podmanTest.Podman([]string{"import", "--change", "CMD=/bin/bash", outfile, "imported-image"}) importImage.WaitWithDefaultTimeout() - Expect(importImage.ExitCode()).To(Equal(0)) + Expect(importImage).Should(Exit(0)) results := podmanTest.Podman([]string{"inspect", "imported-image"}) results.WaitWithDefaultTimeout() - Expect(results.ExitCode()).To(Equal(0)) + Expect(results).Should(Exit(0)) imageData := results.InspectImageJSON() Expect(imageData[0].Config.Cmd[0]).To(Equal("/bin/sh")) Expect(imageData[0].Config.Cmd[1]).To(Equal("-c")) @@ -119,15 +120,15 @@ var _ = Describe("Podman import", func() { export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) export.WaitWithDefaultTimeout() - Expect(export.ExitCode()).To(Equal(0)) + Expect(export).Should(Exit(0)) importImage := podmanTest.Podman([]string{"import", "--change", "CMD /bin/sh", outfile, "imported-image"}) importImage.WaitWithDefaultTimeout() - Expect(importImage.ExitCode()).To(Equal(0)) + Expect(importImage).Should(Exit(0)) results := podmanTest.Podman([]string{"inspect", "imported-image"}) results.WaitWithDefaultTimeout() - Expect(results.ExitCode()).To(Equal(0)) + Expect(results).Should(Exit(0)) imageData := results.InspectImageJSON() Expect(imageData[0].Config.Cmd[0]).To(Equal("/bin/sh")) Expect(imageData[0].Config.Cmd[1]).To(Equal("-c")) @@ -141,15 +142,15 @@ var _ = Describe("Podman import", func() { export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) export.WaitWithDefaultTimeout() - Expect(export.ExitCode()).To(Equal(0)) + Expect(export).Should(Exit(0)) importImage := podmanTest.Podman([]string{"import", "--change", "CMD [\"/bin/bash\"]", outfile, "imported-image"}) importImage.WaitWithDefaultTimeout() - Expect(importImage.ExitCode()).To(Equal(0)) + Expect(importImage).Should(Exit(0)) results := podmanTest.Podman([]string{"inspect", "imported-image"}) results.WaitWithDefaultTimeout() - Expect(results.ExitCode()).To(Equal(0)) + Expect(results).Should(Exit(0)) imageData := results.InspectImageJSON() Expect(imageData[0].Config.Cmd[0]).To(Equal("/bin/bash")) }) @@ -161,14 +162,14 @@ var _ = Describe("Podman import", func() { export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) export.WaitWithDefaultTimeout() - Expect(export.ExitCode()).To(Equal(0)) + Expect(export).Should(Exit(0)) importImage := podmanTest.Podman([]string{"import", "--signature-policy", "/no/such/file", outfile}) importImage.WaitWithDefaultTimeout() - Expect(importImage.ExitCode()).To(Not(Equal(0))) + Expect(importImage).To(ExitWithError()) result := podmanTest.Podman([]string{"import", "--signature-policy", "/etc/containers/policy.json", outfile}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(0)) + Expect(result).Should(Exit(0)) }) }) |