Skip to content

Commit

Permalink
fix: add --all to volume prune tests (#87)
Browse files Browse the repository at this point in the history
Issue #, if available:

*Description of changes:*

*Testing done:*



- [x] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Sam Berning <[email protected]>
  • Loading branch information
sam-berning authored Sep 21, 2023
1 parent 841b4b7 commit 9248bec
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/volume_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega/gbytes"

"github.com/runfinch/common-tests/command"
"github.com/runfinch/common-tests/option"
)
Expand All @@ -25,27 +24,27 @@ func VolumePrune(o *option.Option) {

ginkgo.It("should not remove a volume if it is used by a container", func() {
command.Run(o, "run", "-v", fmt.Sprintf("%s:/tmp", testVolumeName), "--name", testContainerName, defaultImage)
command.Run(o, "volume", "prune", "--force")
command.Run(o, "volume", "prune", "--force", "--all")
volumeShouldExist(o, testVolumeName)
})

ginkgo.It("should remove all unused volumes with inputting y in prompt confirmation", func() {
command.Run(o, "volume", "create", testVolumeName)
command.New(o, "volume", "prune").WithStdin(gbytes.BufferWithBytes([]byte("y"))).Run()
command.New(o, "volume", "prune", "--all").WithStdin(gbytes.BufferWithBytes([]byte("y"))).Run()
volumeShouldNotExist(o, testVolumeName)
})

ginkgo.It("should not remove all unused volumes with inputting n in prompt confirmation", func() {
command.Run(o, "volume", "create", testVolumeName)
command.New(o, "volume", "prune").WithStdin(gbytes.BufferWithBytes([]byte("n"))).Run()
command.New(o, "volume", "prune", "--all").WithStdin(gbytes.BufferWithBytes([]byte("n"))).Run()
volumeShouldExist(o, testVolumeName)
})

for _, force := range []string{"--force", "-f"} {
force := force
ginkgo.It(fmt.Sprintf("should remove all unused volumes without prompting for confirmation with %s flag", force), func() {
command.Run(o, "volume", "create", testVolumeName)
command.Run(o, "volume", "prune", force)
command.Run(o, "volume", "prune", force, "--all")
volumeShouldNotExist(o, testVolumeName)
})
}
Expand Down

0 comments on commit 9248bec

Please sign in to comment.