github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/e2e/pod_prune_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 6 . "github.com/hanks177/podman/v4/test/utils" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 var _ = Describe("Podman pod prune", func() { 13 var ( 14 tempdir string 15 err error 16 podmanTest *PodmanTestIntegration 17 ) 18 19 BeforeEach(func() { 20 tempdir, err = CreateTempDirInTempDir() 21 if err != nil { 22 os.Exit(1) 23 } 24 podmanTest = PodmanTestCreate(tempdir) 25 podmanTest.Setup() 26 }) 27 28 AfterEach(func() { 29 podmanTest.Cleanup() 30 f := CurrentGinkgoTestDescription() 31 processTestResult(f) 32 33 }) 34 35 It("podman pod prune empty pod", func() { 36 _, ec, _ := podmanTest.CreatePod(nil) 37 Expect(ec).To(Equal(0)) 38 39 result := podmanTest.Podman([]string{"pod", "prune", "--force"}) 40 result.WaitWithDefaultTimeout() 41 Expect(result).Should(Exit(0)) 42 }) 43 44 It("podman pod prune doesn't remove a pod with a running container", func() { 45 _, ec, podid := podmanTest.CreatePod(nil) 46 Expect(ec).To(Equal(0)) 47 48 ec2 := podmanTest.RunTopContainerInPod("", podid) 49 ec2.WaitWithDefaultTimeout() 50 Expect(ec2).Should(Exit(0)) 51 52 result := podmanTest.Podman([]string{"pod", "prune", "-f"}) 53 result.WaitWithDefaultTimeout() 54 Expect(result).Should(Exit(0)) 55 56 result = podmanTest.Podman([]string{"ps", "-qa"}) 57 result.WaitWithDefaultTimeout() 58 Expect(result.OutputToStringArray()).To(HaveLen(1)) 59 }) 60 61 It("podman pod prune removes a pod with a stopped container", func() { 62 _, ec, podid := podmanTest.CreatePod(nil) 63 Expect(ec).To(Equal(0)) 64 65 _, ec2, _ := podmanTest.RunLsContainerInPod("", podid) 66 Expect(ec2).To(Equal(0)) 67 68 result := podmanTest.Podman([]string{"pod", "prune", "-f"}) 69 result.WaitWithDefaultTimeout() 70 Expect(result).Should(Exit(0)) 71 72 result = podmanTest.Podman([]string{"ps", "-qa"}) 73 result.WaitWithDefaultTimeout() 74 Expect(result.OutputToStringArray()).To(BeEmpty()) 75 }) 76 })