diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-04-12 15:50:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-12 15:50:22 +0200 |
commit | 0ac73f25eb45611324f255b5222863b6ff0e8525 (patch) | |
tree | f2c8ff0fa46e06b5fd5864765699180b674955c5 /pkg/bindings/test/networks_test.go | |
parent | 9d3e31071087908207a8f7fdc84939edf3dc47c0 (diff) | |
parent | 94b972630643b6f4b472a4b03f58fa757d3ca6a5 (diff) | |
download | podman-0ac73f25eb45611324f255b5222863b6ff0e8525.tar.gz podman-0ac73f25eb45611324f255b5222863b6ff0e8525.tar.bz2 podman-0ac73f25eb45611324f255b5222863b6ff0e8525.zip |
Merge pull request #9988 from jmguzik/prune-filters-bindings-net
Add network prune filters support to bindings
Diffstat (limited to 'pkg/bindings/test/networks_test.go')
-rw-r--r-- | pkg/bindings/test/networks_test.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/pkg/bindings/test/networks_test.go b/pkg/bindings/test/networks_test.go index ef20235ae..df7d7cd1c 100644 --- a/pkg/bindings/test/networks_test.go +++ b/pkg/bindings/test/networks_test.go @@ -37,6 +37,53 @@ var _ = Describe("Podman networks", func() { bt.cleanup() }) + It("podman prune unused networks with filters", func() { + name := "foobar" + opts := network.CreateOptions{ + Name: &name, + } + _, err = network.Create(connText, &opts) + Expect(err).To(BeNil()) + + // Invalid filters should return error + filtersIncorrect := map[string][]string{ + "status": {"dummy"}, + } + _, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filtersIncorrect)) + Expect(err).ToNot(BeNil()) + + // List filter params should not work with prune. + filtersIncorrect = map[string][]string{ + "name": {name}, + } + _, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filtersIncorrect)) + Expect(err).ToNot(BeNil()) + + // Mismatched label, correct filter params => no network should be pruned. + filtersIncorrect = map[string][]string{ + "label": {"xyz"}, + } + pruneResponse, err := network.Prune(connText, new(network.PruneOptions).WithFilters(filtersIncorrect)) + Expect(err).To(BeNil()) + Expect(len(pruneResponse)).To(Equal(0)) + + // Mismatched until, correct filter params => no network should be pruned. + filters := map[string][]string{ + "until": {"50"}, // January 1, 1970 + } + pruneResponse, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filters)) + Expect(err).To(BeNil()) + Expect(len(pruneResponse)).To(Equal(0)) + + // Valid filter params => network should be pruned now. + filters = map[string][]string{ + "until": {"5000000000"}, //June 11, 2128 + } + pruneResponse, err = network.Prune(connText, new(network.PruneOptions).WithFilters(filters)) + Expect(err).To(BeNil()) + Expect(len(pruneResponse)).To(Equal(1)) + }) + It("create network", func() { // create a network with blank config should work _, err = network.Create(connText, &network.CreateOptions{}) |