4
. "github.com/containers/podman/v5/test/utils"
5
. "github.com/onsi/ginkgo/v2"
6
. "github.com/onsi/gomega"
7
. "github.com/onsi/gomega/gexec"
10
var _ = Describe("Podman volume rm", func() {
13
podmanTest.CleanupVolume()
16
It("podman volume rm", func() {
17
session := podmanTest.Podman([]string{"volume", "create", "myvol"})
18
session.WaitWithDefaultTimeout()
19
Expect(session).Should(ExitCleanly())
21
session = podmanTest.Podman([]string{"volume", "rm", "myvol"})
22
session.WaitWithDefaultTimeout()
23
Expect(session).Should(ExitCleanly())
25
session = podmanTest.Podman([]string{"volume", "ls"})
26
session.WaitWithDefaultTimeout()
27
Expect(session).Should(ExitCleanly())
28
Expect(session.OutputToStringArray()).To(BeEmpty())
31
It("podman volume rm with --force flag", func() {
32
session := podmanTest.Podman([]string{"create", "-v", "myvol:/myvol", ALPINE, "ls"})
33
cid := session.OutputToString()
34
session.WaitWithDefaultTimeout()
35
Expect(session).Should(ExitCleanly())
37
session = podmanTest.Podman([]string{"volume", "rm", "myvol"})
38
session.WaitWithDefaultTimeout()
39
Expect(session).Should(Exit(2))
40
Expect(session.ErrorToString()).To(ContainSubstring(cid))
42
session = podmanTest.Podman([]string{"volume", "rm", "-t", "0", "-f", "myvol"})
43
session.WaitWithDefaultTimeout()
44
Expect(session).Should(ExitCleanly())
46
session = podmanTest.Podman([]string{"volume", "ls"})
47
session.WaitWithDefaultTimeout()
48
Expect(session).Should(ExitCleanly())
49
Expect(session.OutputToStringArray()).To(BeEmpty())
52
It("podman volume remove bogus", func() {
53
session := podmanTest.Podman([]string{"volume", "rm", "bogus"})
54
session.WaitWithDefaultTimeout()
55
Expect(session).Should(Exit(1))
58
It("podman rm with --all flag", func() {
59
session := podmanTest.Podman([]string{"volume", "create", "myvol"})
60
session.WaitWithDefaultTimeout()
61
Expect(session).Should(ExitCleanly())
63
session = podmanTest.Podman([]string{"volume", "create"})
64
session.WaitWithDefaultTimeout()
65
Expect(session).Should(ExitCleanly())
67
session = podmanTest.Podman([]string{"volume", "rm", "-a"})
68
session.WaitWithDefaultTimeout()
69
Expect(session).Should(ExitCleanly())
71
session = podmanTest.Podman([]string{"volume", "ls"})
72
session.WaitWithDefaultTimeout()
73
Expect(session).Should(ExitCleanly())
74
Expect(session.OutputToStringArray()).To(BeEmpty())
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())
82
session = podmanTest.Podman([]string{"volume", "rm", "myv"})
83
session.WaitWithDefaultTimeout()
84
Expect(session).Should(ExitCleanly())
86
session = podmanTest.Podman([]string{"volume", "ls"})
87
session.WaitWithDefaultTimeout()
88
Expect(session).Should(ExitCleanly())
89
Expect(session.OutputToStringArray()).To(BeEmpty())
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())
97
session = podmanTest.Podman([]string{"volume", "create", "myvol2"})
98
session.WaitWithDefaultTimeout()
99
Expect(session).Should(ExitCleanly())
101
session = podmanTest.Podman([]string{"volume", "rm", "myv"})
102
session.WaitWithDefaultTimeout()
103
Expect(session).To(ExitWithError())
105
session = podmanTest.Podman([]string{"volume", "ls"})
106
session.WaitWithDefaultTimeout()
107
Expect(session).Should(ExitCleanly())
108
Expect(len(session.OutputToStringArray())).To(BeNumerically(">=", 2))