summaryrefslogtreecommitdiff
path: root/test/e2e/prune_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e/prune_test.go')
-rw-r--r--test/e2e/prune_test.go54
1 files changed, 26 insertions, 28 deletions
diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go
index 223fcc5b2..6a70fd556 100644
--- a/test/e2e/prune_test.go
+++ b/test/e2e/prune_test.go
@@ -98,22 +98,21 @@ var _ = Describe("Podman prune", func() {
session := podmanTest.Podman([]string{"images", "-a"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- hasNone, _ := session.GrepString("<none>")
- Expect(hasNone).To(BeFalse())
+ Expect(session.OutputToString()).To(Not(ContainSubstring("<none>")))
numImages := len(session.OutputToStringArray())
// Since there's no dangling image, none should be removed.
session = podmanTest.Podman([]string{"image", "prune", "-f"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(0))
+ Expect(session.OutputToStringArray()).To(BeEmpty())
// Let's be extra sure that the same number of images is
// reported.
session = podmanTest.Podman([]string{"images", "-a"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(numImages))
+ Expect(session.OutputToStringArray()).To(HaveLen(numImages))
// Now build an image and untag it. The (intermediate) images
// should be removed recursively during pruning.
@@ -125,8 +124,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"images", "-a"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- hasNone, _ = session.GrepString("<none>")
- Expect(hasNone).To(BeTrue()) // ! we have dangling ones
+ Expect(session.OutputToString()).To(ContainSubstring("<none>"))
numImages = len(session.OutputToStringArray())
// Since there's at least one dangling image, prune should
@@ -135,14 +133,14 @@ var _ = Describe("Podman prune", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
numPrunedImages := len(session.OutputToStringArray())
- Expect(numPrunedImages >= 1).To(BeTrue())
+ Expect(numPrunedImages).To(BeNumerically(">=", 1), "numPrunedImages")
// Now make sure that exactly the number of pruned images has
// been removed.
session = podmanTest.Podman([]string{"images", "-a"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(numImages - numPrunedImages))
+ Expect(session.OutputToStringArray()).To(HaveLen(numImages - numPrunedImages))
})
It("podman image prune - handle empty images", func() {
@@ -159,7 +157,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"image", "prune", "-f"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(0))
+ Expect(session.OutputToStringArray()).To(BeEmpty())
// Now the image will be untagged, and its parent images will
// be removed recursively.
@@ -170,7 +168,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"image", "prune", "-f"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(2))
+ Expect(session.OutputToStringArray()).To(HaveLen(2))
})
It("podman image prune dangling images", func() {
@@ -180,7 +178,7 @@ var _ = Describe("Podman prune", func() {
none.WaitWithDefaultTimeout()
Expect(none).Should(Exit(0))
hasNone, result := none.GrepString("<none>")
- Expect(len(result)).To(Equal(2))
+ Expect(result).To(HaveLen(2))
Expect(hasNone).To(BeTrue())
prune := podmanTest.Podman([]string{"image", "prune", "-f"})
@@ -189,11 +187,11 @@ var _ = Describe("Podman prune", func() {
after := podmanTest.Podman([]string{"images", "-a"})
after.WaitWithDefaultTimeout()
- Expect(none).Should(Exit(0))
- hasNoneAfter, result := none.GrepString("<none>")
+ Expect(after).Should(Exit(0))
+ hasNoneAfter, result := after.GrepString("<none>")
Expect(hasNoneAfter).To(BeTrue())
- Expect(len(after.OutputToStringArray()) > 1).To(BeTrue())
- Expect(len(result) > 0).To(BeTrue())
+ Expect(len(after.OutputToStringArray())).To(BeNumerically(">", 1))
+ Expect(len(result)).To(BeNumerically(">", 0))
})
It("podman image prune unused images", func() {
@@ -212,7 +210,7 @@ var _ = Describe("Podman prune", func() {
images.WaitWithDefaultTimeout()
Expect(images).Should(Exit(0))
// all images are unused, so they all should be deleted!
- Expect(len(images.OutputToStringArray())).To(Equal(len(CACHE_IMAGES)))
+ Expect(images.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES)))
})
It("podman system image prune unused images", func() {
@@ -225,7 +223,7 @@ var _ = Describe("Podman prune", func() {
images := podmanTest.Podman([]string{"images", "-aq"})
images.WaitWithDefaultTimeout()
// all images are unused, so they all should be deleted!
- Expect(len(images.OutputToStringArray())).To(Equal(len(CACHE_IMAGES)))
+ Expect(images.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES)))
})
It("podman system prune pods", func() {
@@ -249,7 +247,7 @@ var _ = Describe("Podman prune", func() {
pods := podmanTest.Podman([]string{"pod", "ps"})
pods.WaitWithDefaultTimeout()
Expect(pods).Should(Exit(0))
- Expect(len(pods.OutputToStringArray())).To(Equal(3))
+ Expect(pods.OutputToStringArray()).To(HaveLen(3))
prune := podmanTest.Podman([]string{"system", "prune", "-f"})
prune.WaitWithDefaultTimeout()
@@ -258,7 +256,7 @@ var _ = Describe("Podman prune", func() {
pods = podmanTest.Podman([]string{"pod", "ps"})
pods.WaitWithDefaultTimeout()
Expect(pods).Should(Exit(0))
- Expect(len(pods.OutputToStringArray())).To(Equal(2))
+ Expect(pods.OutputToStringArray()).To(HaveLen(2))
})
It("podman system prune - pod,container stopped", func() {
@@ -346,7 +344,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"volume", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(3))
+ Expect(session.OutputToStringArray()).To(HaveLen(3))
session = podmanTest.Podman([]string{"system", "prune", "--force", "--volumes"})
session.WaitWithDefaultTimeout()
@@ -356,7 +354,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"volume", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(0))
+ Expect(session.OutputToStringArray()).To(BeEmpty())
// One Pod should not be pruned as it was running
Expect(podmanTest.NumberOfPods()).To(Equal(1))
@@ -367,7 +365,7 @@ var _ = Describe("Podman prune", func() {
// Image should not be pruned and number should be same.
images := podmanTest.Podman([]string{"images"})
images.WaitWithDefaultTimeout()
- Expect(len(images.OutputToStringArray())).To(Equal(numberOfImages))
+ Expect(images.OutputToStringArray()).To(HaveLen(numberOfImages))
})
It("podman system prune - with dangling images true", func() {
@@ -410,12 +408,12 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"volume", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(2))
+ Expect(session.OutputToStringArray()).To(HaveLen(2))
images := podmanTest.Podman([]string{"images", "-aq"})
images.WaitWithDefaultTimeout()
// all images are unused, so they all should be deleted!
- Expect(len(images.OutputToStringArray())).To(Equal(len(CACHE_IMAGES)))
+ Expect(images.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES)))
})
It("podman system prune --volumes --filter", func() {
@@ -446,7 +444,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"volume", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(7))
+ Expect(session.OutputToStringArray()).To(HaveLen(7))
session = podmanTest.Podman([]string{"system", "prune", "--force", "--volumes", "--filter", "label=label1=value1"})
session.WaitWithDefaultTimeout()
@@ -455,7 +453,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"volume", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(6))
+ Expect(session.OutputToStringArray()).To(HaveLen(6))
session = podmanTest.Podman([]string{"system", "prune", "--force", "--volumes", "--filter", "label=sharedlabel1=slv1"})
session.WaitWithDefaultTimeout()
@@ -464,7 +462,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"volume", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(5))
+ Expect(session.OutputToStringArray()).To(HaveLen(5))
session = podmanTest.Podman([]string{"system", "prune", "--force", "--volumes", "--filter", "label=sharedlabel1"})
session.WaitWithDefaultTimeout()
@@ -473,7 +471,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"volume", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- Expect(len(session.OutputToStringArray())).To(Equal(3))
+ Expect(session.OutputToStringArray()).To(HaveLen(3))
podmanTest.Cleanup()
})