aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-01-26 06:32:31 +0100
committerDaniel J Walsh <dwalsh@redhat.com>2020-01-28 16:34:18 -0500
commit38d2ef0cbd32a68a6d2c74b35d75fd9b14a3867a (patch)
treeac710a858a59b865a614c699eeff9908cabb71df /test
parentbb7f72bbd607c89660ce5bf7fd57234bcf7cfa08 (diff)
downloadpodman-38d2ef0cbd32a68a6d2c74b35d75fd9b14a3867a.tar.gz
podman-38d2ef0cbd32a68a6d2c74b35d75fd9b14a3867a.tar.bz2
podman-38d2ef0cbd32a68a6d2c74b35d75fd9b14a3867a.zip
Throw error on invalid sort value
We define the valid sort values, so we should throw an error on invalid sort values. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/images_test.go32
1 files changed, 21 insertions, 11 deletions
diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go
index 80e6d4444..9a67cc83a 100644
--- a/test/e2e/images_test.go
+++ b/test/e2e/images_test.go
@@ -270,26 +270,36 @@ RUN apk update && apk add man
Expect(result.ExitCode()).To(Equal(0))
})
- It("podman images sort by tag", func() {
- session := podmanTest.Podman([]string{"images", "--sort", "tag", "--format={{.Tag}}"})
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ It("podman images sort by values", func() {
+ sortValueTest := func(value string, result int, format string) []string {
+ f := fmt.Sprintf("{{.%s}}", format)
+ session := podmanTest.Podman([]string{"images", "--sort", value, "--format", f})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(result))
+
+ return session.OutputToStringArray()
+ }
- sortedArr := session.OutputToStringArray()
+ sortedArr := sortValueTest("created", 0, "CreatedTime")
+ Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool { return sortedArr[i] > sortedArr[j] })).To(BeTrue())
+
+ sortedArr = sortValueTest("id", 0, "ID")
Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool { return sortedArr[i] < sortedArr[j] })).To(BeTrue())
- })
- It("podman images sort by size", func() {
- session := podmanTest.Podman([]string{"images", "--sort", "size", "--format={{.Size}}"})
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
+ sortedArr = sortValueTest("repository", 0, "Repository")
+ Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool { return sortedArr[i] < sortedArr[j] })).To(BeTrue())
- sortedArr := session.OutputToStringArray()
+ sortedArr = sortValueTest("size", 0, "Size")
Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool {
size1, _ := units.FromHumanSize(sortedArr[i])
size2, _ := units.FromHumanSize(sortedArr[j])
return size1 < size2
})).To(BeTrue())
+ sortedArr = sortValueTest("tag", 0, "Tag")
+ Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool { return sortedArr[i] < sortedArr[j] })).To(BeTrue())
+
+ sortValueTest("badvalue", 125, "Tag")
+ sortValueTest("id", 125, "badvalue")
})
It("podman images --all flag", func() {