Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add --all to volume prune tests #87

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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