mirror of
https://github.com/containers/podman.git
synced 2025-12-13 18:37:36 +08:00
Merge pull request #7825 from rhatdan/exitcode
Fix handling of remove of bogus volumes, networks and Pods
This commit is contained in:
@@ -265,6 +265,12 @@ var _ = Describe("Podman network", func() {
|
||||
Expect(rmAll.ExitCode()).To(BeZero())
|
||||
})
|
||||
|
||||
It("podman network remove bogus", func() {
|
||||
session := podmanTest.Podman([]string{"network", "rm", "bogus"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(1))
|
||||
})
|
||||
|
||||
It("podman network remove --force with pod", func() {
|
||||
netName := "testnet"
|
||||
session := podmanTest.Podman([]string{"network", "create", netName})
|
||||
@@ -280,6 +286,10 @@ var _ = Describe("Podman network", func() {
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(BeZero())
|
||||
|
||||
session = podmanTest.Podman([]string{"network", "rm", netName})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(2))
|
||||
|
||||
session = podmanTest.Podman([]string{"network", "rm", "--force", netName})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(BeZero())
|
||||
|
||||
@@ -195,8 +195,7 @@ var _ = Describe("Podman pod rm", func() {
|
||||
It("podman rm bogus pod", func() {
|
||||
session := podmanTest.Podman([]string{"pod", "rm", "bogus"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
// TODO: `podman rm` returns 1 for a bogus container. Should the RC be consistent?
|
||||
Expect(session.ExitCode()).To(Equal(125))
|
||||
Expect(session.ExitCode()).To(Equal(1))
|
||||
})
|
||||
|
||||
It("podman rm bogus pod and a running pod", func() {
|
||||
@@ -209,11 +208,11 @@ var _ = Describe("Podman pod rm", func() {
|
||||
|
||||
session = podmanTest.Podman([]string{"pod", "rm", "bogus", "test1"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(125))
|
||||
Expect(session.ExitCode()).To(Equal(1))
|
||||
|
||||
session = podmanTest.Podman([]string{"pod", "rm", "test1", "bogus"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(125))
|
||||
Expect(session.ExitCode()).To(Equal(1))
|
||||
})
|
||||
|
||||
It("podman rm --ignore bogus pod and a running pod", func() {
|
||||
|
||||
@@ -228,11 +228,11 @@ var _ = Describe("Podman rm", func() {
|
||||
|
||||
session = podmanTest.Podman([]string{"rm", "bogus", "test1"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(125))
|
||||
Expect(session.ExitCode()).To(Equal(1))
|
||||
|
||||
session = podmanTest.Podman([]string{"rm", "test1", "bogus"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(125))
|
||||
Expect(session.ExitCode()).To(Equal(1))
|
||||
})
|
||||
|
||||
It("podman rm --ignore bogus container and a running container", func() {
|
||||
|
||||
@@ -55,7 +55,7 @@ var _ = Describe("Podman volume rm", func() {
|
||||
|
||||
session = podmanTest.Podman([]string{"volume", "rm", "myvol"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).To(ExitWithError())
|
||||
Expect(session.ExitCode()).To(Equal(2))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring(cid))
|
||||
|
||||
session = podmanTest.Podman([]string{"volume", "rm", "-f", "myvol"})
|
||||
@@ -70,6 +70,12 @@ var _ = Describe("Podman volume rm", func() {
|
||||
podmanTest.Cleanup()
|
||||
})
|
||||
|
||||
It("podman volume remove bogus", func() {
|
||||
session := podmanTest.Podman([]string{"volume", "rm", "bogus"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(1))
|
||||
})
|
||||
|
||||
It("podman rm with --all flag", func() {
|
||||
session := podmanTest.Podman([]string{"volume", "create", "myvol"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
||||
@@ -99,7 +99,7 @@ load helpers
|
||||
"Trying to create an already-existing network"
|
||||
|
||||
run_podman network rm $mynetname
|
||||
run_podman 125 network rm $mynetname
|
||||
run_podman 1 network rm $mynetname
|
||||
|
||||
# rootless CNI leaves behind an image pulled by SHA, hence with no tag.
|
||||
# Remove it if present; we can only remove it by ID.
|
||||
|
||||
Reference in New Issue
Block a user