From b868470238ee60032a50f6ed23db3c09b475842b Mon Sep 17 00:00:00 2001 From: haircommander Date: Mon, 11 Jun 2018 16:46:16 -0400 Subject: Added --sort flag to podman image Signed-off-by: haircommander Closes: #937 Approved by: rhatdan --- test/e2e/images_test.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'test/e2e') diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 8b9b889aa..5e30e95ec 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -1,9 +1,11 @@ package integration import ( + "fmt" "os" + "sort" - "fmt" + "github.com/docker/go-units" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -28,7 +30,6 @@ var _ = Describe("Podman images", func() { podmanTest.Cleanup() }) - It("podman images", func() { session := podmanTest.Podman([]string{"images"}) session.WaitWithDefaultTimeout() @@ -143,4 +144,25 @@ var _ = Describe("Podman images", func() { 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)) + + sortedArr := session.OutputToStringArray() + 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 := session.OutputToStringArray() + Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool { + size1, _ := units.FromHumanSize(sortedArr[i]) + size2, _ := units.FromHumanSize(sortedArr[j]) + return size1 < size2 + })).To(BeTrue()) + }) }) -- cgit v1.2.3-54-g00ecf