podman pod exists

like containers and images, users would benefit from being able to check
if a pod exists in local storage.  if the pod exists, the return code is 0.
if the pod does not exists, the return code is 1.  Any other return code
indicates a real errors, such as permissions or runtime.

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude
2018-12-01 13:51:58 -06:00
parent 5bb66a47a4
commit 318bf7017b
5 changed files with 118 additions and 0 deletions

View File

@ -82,4 +82,36 @@ var _ = Describe("Podman image|container exists", func() {
Expect(session.ExitCode()).To(Equal(1))
})
It("podman pod exists in local storage by name", func() {
setup, rc, _ := podmanTest.CreatePod("foobar")
setup.WaitWithDefaultTimeout()
Expect(rc).To(Equal(0))
session := podmanTest.Podman([]string{"pod", "exists", "foobar"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
})
It("podman pod exists in local storage by container ID", func() {
setup, rc, podID := podmanTest.CreatePod("")
setup.WaitWithDefaultTimeout()
Expect(rc).To(Equal(0))
session := podmanTest.Podman([]string{"pod", "exists", podID})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
})
It("podman pod exists in local storage by short container ID", func() {
setup, rc, podID := podmanTest.CreatePod("")
setup.WaitWithDefaultTimeout()
Expect(rc).To(Equal(0))
session := podmanTest.Podman([]string{"pod", "exists", podID[0:12]})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
})
It("podman pod does not exist in local storage", func() {
session := podmanTest.Podman([]string{"pod", "exists", "foobar"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(1))
})
})