summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-04-02 14:35:10 +0200
committerGitHub <noreply@github.com>2021-04-02 14:35:10 +0200
commit1db9053add6501f2c234a6f63bb1e74b5eb89cb0 (patch)
treecd905214eb28d789147998697fe9a26725017c47
parent3ae42358e13a25abdb1caa65c529e8171804095c (diff)
parentc5beaf0e17185f6425df1f9db8fccbca370200cb (diff)
downloadpodman-1db9053add6501f2c234a6f63bb1e74b5eb89cb0.tar.gz
podman-1db9053add6501f2c234a6f63bb1e74b5eb89cb0.tar.bz2
podman-1db9053add6501f2c234a6f63bb1e74b5eb89cb0.zip
Merge pull request #9912 from jmguzik/recreate-prune-until-tests-for-containers
Recreate until container prune tests for bindings
-rw-r--r--pkg/bindings/test/containers_test.go29
-rw-r--r--pkg/domain/filters/containers.go2
2 files changed, 30 insertions, 1 deletions
diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go
index 4f049d18b..4d1361746 100644
--- a/pkg/bindings/test/containers_test.go
+++ b/pkg/bindings/test/containers_test.go
@@ -568,6 +568,35 @@ var _ = Describe("Podman containers ", func() {
Expect(err).To(BeNil())
Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(0))
Expect(len(reports.PruneReportsErrs(pruneResponse))).To(Equal(0))
+
+ // Valid filter params container should be pruned now.
+ filters := map[string][]string{
+ "until": {"5000000000"}, //Friday, June 11, 2128
+ }
+ pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filters))
+ Expect(err).To(BeNil())
+ Expect(len(reports.PruneReportsErrs(pruneResponse))).To(Equal(0))
+ Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(1))
+ })
+
+ It("podman list containers with until filter", func() {
+ var name = "top"
+ _, err := bt.RunTopContainer(&name, nil)
+ Expect(err).To(BeNil())
+
+ filters := map[string][]string{
+ "until": {"5000000000"}, //Friday, June 11, 2128
+ }
+ c, err := containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true))
+ Expect(err).To(BeNil())
+ Expect(len(c)).To(Equal(1))
+
+ filters = map[string][]string{
+ "until": {"500000"}, // Tuesday, January 6, 1970
+ }
+ c, err = containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true))
+ Expect(err).To(BeNil())
+ Expect(len(c)).To(Equal(0))
})
It("podman prune running containers", func() {
diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go
index 19d704da1..45791cd84 100644
--- a/pkg/domain/filters/containers.go
+++ b/pkg/domain/filters/containers.go
@@ -237,7 +237,7 @@ func prepareUntilFilterFunc(filterValues []string) (func(container *libpod.Conta
return nil, err
}
return func(c *libpod.Container) bool {
- if !until.IsZero() && c.CreatedTime().After((until)) {
+ if !until.IsZero() && c.CreatedTime().Before(until) {
return true
}
return false