diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 5caec5f6da..bc5d2d1fa2 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -7,7 +7,6 @@ import ( . "github.com/containers/podman/v5/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) var _ = Describe("Podman rmi", func() { @@ -15,7 +14,7 @@ var _ = Describe("Podman rmi", func() { It("podman rmi bogus image", func() { session := podmanTest.Podman([]string{"rmi", "debian:6.0.10"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1, "debian:6.0.10: image not known")) }) @@ -72,10 +71,10 @@ var _ = Describe("Podman rmi", func() { It("podman rmi image with tags by ID cannot be done without force", func() { podmanTest.AddImageToRWStore(CIRROS_IMAGE) - setup := podmanTest.Podman([]string{"images", "-q", CIRROS_IMAGE}) + setup := podmanTest.Podman([]string{"images", "-q", "--no-trunc", CIRROS_IMAGE}) setup.WaitWithDefaultTimeout() Expect(setup).Should(ExitCleanly()) - cirrosID := setup.OutputToString() + cirrosID := setup.OutputToString()[7:] session := podmanTest.Podman([]string{"tag", "cirros", "foo:bar", "foo"}) session.WaitWithDefaultTimeout() @@ -84,7 +83,7 @@ var _ = Describe("Podman rmi", func() { // Trying without --force should fail result := podmanTest.Podman([]string{"rmi", cirrosID}) result.WaitWithDefaultTimeout() - Expect(result).To(ExitWithError()) + Expect(result).To(ExitWithError(125, fmt.Sprintf(`unable to delete image "%s" by ID with more than one tag ([localhost/foo:latest localhost/foo:bar %s]): please force removal`, cirrosID, CIRROS_IMAGE))) // With --force it should work resultForce := podmanTest.Podman([]string{"rmi", "-f", cirrosID}) @@ -93,7 +92,6 @@ var _ = Describe("Podman rmi", func() { }) It("podman rmi image that is a parent of another image", func() { - Skip("I need help with this one. i don't understand what is going on") podmanTest.AddImageToRWStore(CIRROS_IMAGE) session := podmanTest.Podman([]string{"run", "--name", "c_test", CIRROS_IMAGE, "true"}) session.WaitWithDefaultTimeout() @@ -110,22 +108,18 @@ var _ = Describe("Podman rmi", func() { session = podmanTest.Podman([]string{"rmi", CIRROS_IMAGE}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - - session = podmanTest.Podman([]string{"images", "-q"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) - Expect(session.OutputToStringArray()).To(HaveLen(12)) + Expect(session.OutputToString()).To(Equal("Untagged: " + CIRROS_IMAGE)) session = podmanTest.Podman([]string{"images", "--sort", "created", "--format", "{{.Id}}", "--all"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - Expect(session.OutputToStringArray()).To(HaveLen(13), - "Output from 'podman images -q -a'") + Expect(session.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES)+1), + "Output from 'podman images'") untaggedImg := session.OutputToStringArray()[1] session = podmanTest.Podman([]string{"rmi", "-f", untaggedImg}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(2), "UntaggedImg is '%s'", untaggedImg) + Expect(session).Should(ExitWithError(125, fmt.Sprintf(`cannot remove read-only image "%s"`, untaggedImg))) }) It("podman rmi image that is created from another named imaged", func() { @@ -253,8 +247,7 @@ RUN find $LOCAL It("podman image rm is the same as rmi", func() { session := podmanTest.Podman([]string{"image", "rm"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("image name or ID must be specified")) + Expect(session).Should(ExitWithError(125, "image name or ID must be specified")) }) It("podman image rm - concurrent with shared layers", func() {