Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Boaz Shuster <[email protected]>
  • Loading branch information
boaz0 committed Jun 16, 2022
1 parent f1ed11e commit 9e20cfd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/e2e/volume_ls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,37 @@ var _ = Describe("Podman volume ls", func() {
Expect(lsDangling).Should(Exit(0))
Expect(lsDangling.OutputToString()).To(ContainSubstring(volName1))
})

It("podman ls volume with --filter name", func() {
volName1 := "volume1"
session := podmanTest.Podman([]string{"volume", "create", volName1})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

volName2 := "volume2"
session2 := podmanTest.Podman([]string{"volume", "create", volName2})
session2.WaitWithDefaultTimeout()
Expect(session2).Should(Exit(0))

session = podmanTest.Podman([]string{"volume", "ls", "--filter", "name=volume*"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToStringArray()).To(HaveLen(3))
Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName1))
Expect(session.OutputToStringArray()[2]).To(ContainSubstring(volName2))

session = podmanTest.Podman([]string{"volume", "ls", "--filter", "name=volumex"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToStringArray()).To(BeEmpty())

session = podmanTest.Podman([]string{"volume", "ls", "--filter", "name=volume1"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToStringArray()).To(HaveLen(2))
Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName1))
})

It("podman ls volume with multiple --filter flag", func() {
session := podmanTest.Podman([]string{"volume", "create", "--label", "foo=bar", "myvol"})
volName := session.OutputToString()
Expand Down
22 changes: 22 additions & 0 deletions test/system/160-volumes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ function teardown() {
}


# Filter volumes by name
@test "podman volume filter --name" {
suffix=$(random_string)
prefix="volume"

for i in 1 2; do
myvolume=${prefix}_${i}_${suffix}
run_podman volume create $myvolume
is "$output" "$myvolume" "output from volume create $i"
done

run_podman volume ls --filter name=${prefix}_1.+ --format "{{.Name}}"
is "$output" "${prefix}_1_${suffix}" "--filter name=${prefix}_1.+ shows only one volume"

run_podman volume ls --filter name=${prefix}* --format "{{.Name}}"
is "$output" "${prefix}_1_${suffix}.*${prefix}_2_${suffix}$" "--filter name=${prefix}* shows ${prefix}_1 and ${prefix}_2"

for i in 1 2; do
run_podman volume rm ${prefix}_${i}
done
}

# Named volumes
@test "podman volume create / run" {
myvolume=myvol$(random_string)
Expand Down

0 comments on commit 9e20cfd

Please sign in to comment.