github.com/containers/podman/v5@v5.1.0-rc1/test/e2e/volume_rm_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 6 . "github.com/containers/podman/v5/test/utils" 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 ) 10 11 var _ = Describe("Podman volume rm", func() { 12 13 AfterEach(func() { 14 podmanTest.CleanupVolume() 15 }) 16 17 It("podman volume rm", func() { 18 session := podmanTest.Podman([]string{"volume", "create", "myvol"}) 19 session.WaitWithDefaultTimeout() 20 Expect(session).Should(ExitCleanly()) 21 22 session = podmanTest.Podman([]string{"volume", "rm", "myvol"}) 23 session.WaitWithDefaultTimeout() 24 Expect(session).Should(ExitCleanly()) 25 26 session = podmanTest.Podman([]string{"volume", "ls"}) 27 session.WaitWithDefaultTimeout() 28 Expect(session).Should(ExitCleanly()) 29 Expect(session.OutputToStringArray()).To(BeEmpty()) 30 }) 31 32 It("podman volume rm with --force flag", func() { 33 session := podmanTest.Podman([]string{"create", "-v", "myvol:/myvol", ALPINE, "ls"}) 34 session.WaitWithDefaultTimeout() 35 Expect(session).Should(ExitCleanly()) 36 cid := session.OutputToString() 37 38 session = podmanTest.Podman([]string{"volume", "rm", "myvol"}) 39 session.WaitWithDefaultTimeout() 40 Expect(session).Should(ExitWithError(2, fmt.Sprintf("volume myvol is being used by the following container(s): %s: volume is being used", cid))) 41 42 session = podmanTest.Podman([]string{"volume", "rm", "-t", "0", "-f", "myvol"}) 43 session.WaitWithDefaultTimeout() 44 Expect(session).Should(ExitCleanly()) 45 46 session = podmanTest.Podman([]string{"volume", "ls"}) 47 session.WaitWithDefaultTimeout() 48 Expect(session).Should(ExitCleanly()) 49 Expect(session.OutputToStringArray()).To(BeEmpty()) 50 }) 51 52 It("podman volume remove bogus", func() { 53 session := podmanTest.Podman([]string{"volume", "rm", "bogus"}) 54 session.WaitWithDefaultTimeout() 55 Expect(session).Should(ExitWithError(1, `no volume with name "bogus" found: no such volume`)) 56 }) 57 58 It("podman rm with --all flag", func() { 59 session := podmanTest.Podman([]string{"volume", "create", "myvol"}) 60 session.WaitWithDefaultTimeout() 61 Expect(session).Should(ExitCleanly()) 62 63 session = podmanTest.Podman([]string{"volume", "create"}) 64 session.WaitWithDefaultTimeout() 65 Expect(session).Should(ExitCleanly()) 66 67 session = podmanTest.Podman([]string{"volume", "rm", "-a"}) 68 session.WaitWithDefaultTimeout() 69 Expect(session).Should(ExitCleanly()) 70 71 session = podmanTest.Podman([]string{"volume", "ls"}) 72 session.WaitWithDefaultTimeout() 73 Expect(session).Should(ExitCleanly()) 74 Expect(session.OutputToStringArray()).To(BeEmpty()) 75 }) 76 77 It("podman volume rm by partial name", func() { 78 session := podmanTest.Podman([]string{"volume", "create", "myvol"}) 79 session.WaitWithDefaultTimeout() 80 Expect(session).Should(ExitCleanly()) 81 82 session = podmanTest.Podman([]string{"volume", "rm", "myv"}) 83 session.WaitWithDefaultTimeout() 84 Expect(session).Should(ExitCleanly()) 85 86 session = podmanTest.Podman([]string{"volume", "ls"}) 87 session.WaitWithDefaultTimeout() 88 Expect(session).Should(ExitCleanly()) 89 Expect(session.OutputToStringArray()).To(BeEmpty()) 90 }) 91 92 It("podman volume rm by nonunique partial name", func() { 93 session := podmanTest.Podman([]string{"volume", "create", "myvol1"}) 94 session.WaitWithDefaultTimeout() 95 Expect(session).Should(ExitCleanly()) 96 97 session = podmanTest.Podman([]string{"volume", "create", "myvol2"}) 98 session.WaitWithDefaultTimeout() 99 Expect(session).Should(ExitCleanly()) 100 101 session = podmanTest.Podman([]string{"volume", "rm", "myv"}) 102 session.WaitWithDefaultTimeout() 103 expect := "more than one result for volume name myv: volume already exists" 104 if podmanTest.DatabaseBackend == "boltdb" { 105 // boltdb issues volume name in quotes 106 expect = `more than one result for volume name "myv": volume already exists` 107 } 108 if IsRemote() { 109 // FIXME: #22616 110 expect = `unmarshalling error into &errorhandling.ErrorModel` 111 } 112 Expect(session).To(ExitWithError(125, expect)) 113 114 session = podmanTest.Podman([]string{"volume", "ls"}) 115 session.WaitWithDefaultTimeout() 116 Expect(session).Should(ExitCleanly()) 117 Expect(len(session.OutputToStringArray())).To(BeNumerically(">=", 2)) 118 }) 119 })