Skip to content

Commit

Permalink
Merge pull request containers#9912 from jmguzik/recreate-prune-until-…
Browse files Browse the repository at this point in the history
…tests-for-containers

Recreate until container prune tests for bindings
  • Loading branch information
openshift-merge-robot authored Apr 2, 2021
2 parents 3ae4235 + c5beaf0 commit 1db9053
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions pkg/bindings/test/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/domain/filters/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1db9053

Please sign in to comment.