summaryrefslogtreecommitdiff
path: root/pkg/bindings/test
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-12-17 17:22:37 +0000
committerGitHub <noreply@github.com>2020-12-17 17:22:37 +0000
commita17afa931d1aa73b8657cf26de3b49841837f66d (patch)
tree8b3e3408eea4fa15320f5c294d96b8e134bf49c4 /pkg/bindings/test
parent033336606f8aa9687cbdff5450c691b48d45e8e6 (diff)
parent86335aa4ae01dadecd36468409d742e68b76925d (diff)
downloadpodman-a17afa931d1aa73b8657cf26de3b49841837f66d.tar.gz
podman-a17afa931d1aa73b8657cf26de3b49841837f66d.tar.bz2
podman-a17afa931d1aa73b8657cf26de3b49841837f66d.zip
Merge pull request #8752 from baude/bindings3volumes
misc bindings to podman v3
Diffstat (limited to 'pkg/bindings/test')
-rw-r--r--pkg/bindings/test/info_test.go4
-rw-r--r--pkg/bindings/test/manifests_test.go29
-rw-r--r--pkg/bindings/test/system_test.go18
-rw-r--r--pkg/bindings/test/volumes_test.go48
4 files changed, 53 insertions, 46 deletions
diff --git a/pkg/bindings/test/info_test.go b/pkg/bindings/test/info_test.go
index 735de25b8..c4473cd19 100644
--- a/pkg/bindings/test/info_test.go
+++ b/pkg/bindings/test/info_test.go
@@ -34,7 +34,7 @@ var _ = Describe("Podman info", func() {
})
It("podman info", func() {
- info, err := system.Info(bt.conn)
+ info, err := system.Info(bt.conn, nil)
Expect(err).To(BeNil())
Expect(info.Host.Arch).To(Equal(runtime.GOARCH))
Expect(info.Host.OS).To(Equal(runtime.GOOS))
@@ -62,7 +62,7 @@ var _ = Describe("Podman info", func() {
_, err = bt.RunTopContainer(nil, nil, nil)
Expect(err).To(BeNil())
- info, err := system.Info(bt.conn)
+ info, err := system.Info(bt.conn, nil)
Expect(err).To(BeNil())
Expect(info.Store.ContainerStore.Number).To(BeNumerically("==", 4))
diff --git a/pkg/bindings/test/manifests_test.go b/pkg/bindings/test/manifests_test.go
index 421004b8c..b93f64b4b 100644
--- a/pkg/bindings/test/manifests_test.go
+++ b/pkg/bindings/test/manifests_test.go
@@ -4,7 +4,6 @@ import (
"net/http"
"time"
- "github.com/containers/podman/v2/libpod/image"
"github.com/containers/podman/v2/pkg/bindings"
"github.com/containers/podman/v2/pkg/bindings/images"
"github.com/containers/podman/v2/pkg/bindings/manifests"
@@ -37,7 +36,7 @@ var _ = Describe("Podman containers ", func() {
// create manifest list without images
id, err := manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{}, nil)
Expect(err).To(BeNil())
- list, err := manifests.Inspect(bt.conn, id)
+ list, err := manifests.Inspect(bt.conn, id, nil)
Expect(err).To(BeNil())
Expect(len(list.Manifests)).To(BeZero())
@@ -53,13 +52,13 @@ var _ = Describe("Podman containers ", func() {
// create manifest list with images
id, err = manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{alpine.name}, nil)
Expect(err).To(BeNil())
- list, err = manifests.Inspect(bt.conn, id)
+ list, err = manifests.Inspect(bt.conn, id, nil)
Expect(err).To(BeNil())
Expect(len(list.Manifests)).To(BeNumerically("==", 1))
})
It("inspect bogus manifest", func() {
- _, err := manifests.Inspect(bt.conn, "larry")
+ _, err := manifests.Inspect(bt.conn, "larry", nil)
Expect(err).ToNot(BeNil())
code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound))
@@ -67,23 +66,23 @@ var _ = Describe("Podman containers ", func() {
It("add manifest", func() {
// add to bogus should 404
- _, err := manifests.Add(bt.conn, "foobar", image.ManifestAddOpts{})
+ _, err := manifests.Add(bt.conn, "foobar", nil)
Expect(err).ToNot(BeNil())
code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound))
id, err := manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{}, nil)
Expect(err).To(BeNil())
- opts := image.ManifestAddOpts{Images: []string{alpine.name}}
- _, err = manifests.Add(bt.conn, id, opts)
+ options := new(manifests.AddOptions).WithImages([]string{alpine.name})
+ _, err = manifests.Add(bt.conn, id, options)
Expect(err).To(BeNil())
- list, err := manifests.Inspect(bt.conn, id)
+ list, err := manifests.Inspect(bt.conn, id, nil)
Expect(err).To(BeNil())
Expect(len(list.Manifests)).To(BeNumerically("==", 1))
// add bogus name to existing list should fail
- opts.Images = []string{"larry"}
- _, err = manifests.Add(bt.conn, id, opts)
+ options.WithImages([]string{"larry"})
+ _, err = manifests.Add(bt.conn, id, options)
Expect(err).ToNot(BeNil())
code, _ = bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
@@ -91,29 +90,29 @@ var _ = Describe("Podman containers ", func() {
It("remove manifest", func() {
// removal on bogus manifest list should be 404
- _, err := manifests.Remove(bt.conn, "larry", "1234")
+ _, err := manifests.Remove(bt.conn, "larry", "1234", nil)
Expect(err).ToNot(BeNil())
code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound))
id, err := manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{alpine.name}, nil)
Expect(err).To(BeNil())
- data, err := manifests.Inspect(bt.conn, id)
+ data, err := manifests.Inspect(bt.conn, id, nil)
Expect(err).To(BeNil())
Expect(len(data.Manifests)).To(BeNumerically("==", 1))
// removal on a good manifest list with a bad digest should be 400
- _, err = manifests.Remove(bt.conn, id, "!234")
+ _, err = manifests.Remove(bt.conn, id, "!234", nil)
Expect(err).ToNot(BeNil())
code, _ = bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusBadRequest))
digest := data.Manifests[0].Digest.String()
- _, err = manifests.Remove(bt.conn, id, digest)
+ _, err = manifests.Remove(bt.conn, id, digest, nil)
Expect(err).To(BeNil())
// removal on good manifest with good digest should work
- data, err = manifests.Inspect(bt.conn, id)
+ data, err = manifests.Inspect(bt.conn, id, nil)
Expect(err).To(BeNil())
Expect(len(data.Manifests)).To(BeZero())
})
diff --git a/pkg/bindings/test/system_test.go b/pkg/bindings/test/system_test.go
index 82e5c7541..8a8c94d09 100644
--- a/pkg/bindings/test/system_test.go
+++ b/pkg/bindings/test/system_test.go
@@ -56,8 +56,8 @@ var _ = Describe("Podman system", func() {
eventCounter++
}
}()
-
- err = system.Events(bt.conn, binChan, nil, nil, nil, filters, bindings.PFalse)
+ options := new(system.EventsOptions).WithFilters(filters).WithStream(false)
+ err = system.Events(bt.conn, binChan, nil, options)
Expect(err).To(BeNil())
done.Lock()
Expect(eventCounter).To(BeNumerically(">", 0))
@@ -76,7 +76,8 @@ var _ = Describe("Podman system", func() {
err = containers.Stop(bt.conn, name, nil)
Expect(err).To(BeNil())
- systemPruneResponse, err := system.Prune(bt.conn, bindings.PTrue, bindings.PFalse)
+ options := new(system.PruneOptions).WithAll(true)
+ systemPruneResponse, err := system.Prune(bt.conn, options)
Expect(err).To(BeNil())
Expect(len(systemPruneResponse.PodPruneReport)).To(Equal(1))
Expect(len(systemPruneResponse.ContainerPruneReport.ID)).To(Equal(1))
@@ -107,10 +108,10 @@ var _ = Describe("Podman system", func() {
Expect(err).To(BeNil())
// Adding an unused volume
- _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{})
+ _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil())
-
- systemPruneResponse, err := system.Prune(bt.conn, bindings.PTrue, bindings.PFalse)
+ options := new(system.PruneOptions).WithAll(true)
+ systemPruneResponse, err := system.Prune(bt.conn, options)
Expect(err).To(BeNil())
Expect(len(systemPruneResponse.PodPruneReport)).To(Equal(1))
Expect(len(systemPruneResponse.ContainerPruneReport.ID)).To(Equal(1))
@@ -141,10 +142,11 @@ var _ = Describe("Podman system", func() {
Expect(err).To(BeNil())
// Adding an unused volume should work
- _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{})
+ _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil())
- systemPruneResponse, err := system.Prune(bt.conn, bindings.PTrue, bindings.PTrue)
+ options := new(system.PruneOptions).WithAll(true).WithVolumes(true)
+ systemPruneResponse, err := system.Prune(bt.conn, options)
Expect(err).To(BeNil())
Expect(len(systemPruneResponse.PodPruneReport)).To(Equal(0))
Expect(len(systemPruneResponse.ContainerPruneReport.ID)).To(Equal(1))
diff --git a/pkg/bindings/test/volumes_test.go b/pkg/bindings/test/volumes_test.go
index 861a02441..0664a99e4 100644
--- a/pkg/bindings/test/volumes_test.go
+++ b/pkg/bindings/test/volumes_test.go
@@ -52,7 +52,7 @@ var _ = Describe("Podman volumes", func() {
It("create volume", func() {
// create a volume with blank config should work
- _, err := volumes.Create(connText, entities.VolumeCreateOptions{})
+ _, err := volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil())
vcc := entities.VolumeCreateOptions{
@@ -60,21 +60,21 @@ var _ = Describe("Podman volumes", func() {
Label: nil,
Options: nil,
}
- vol, err := volumes.Create(connText, vcc)
+ vol, err := volumes.Create(connText, vcc, nil)
Expect(err).To(BeNil())
Expect(vol.Name).To(Equal("foobar"))
// create volume with same name should 500
- _, err = volumes.Create(connText, vcc)
+ _, err = volumes.Create(connText, vcc, nil)
Expect(err).ToNot(BeNil())
code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
})
It("inspect volume", func() {
- vol, err := volumes.Create(connText, entities.VolumeCreateOptions{})
+ vol, err := volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil())
- data, err := volumes.Inspect(connText, vol.Name)
+ data, err := volumes.Inspect(connText, vol.Name, nil)
Expect(err).To(BeNil())
Expect(data.Name).To(Equal(vol.Name))
})
@@ -86,13 +86,13 @@ var _ = Describe("Podman volumes", func() {
Expect(code).To(BeNumerically("==", http.StatusNotFound))
// Removing an unused volume should work
- vol, err := volumes.Create(connText, entities.VolumeCreateOptions{})
+ vol, err := volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil())
err = volumes.Remove(connText, vol.Name, nil)
Expect(err).To(BeNil())
// Removing a volume that is being used without force should be 409
- vol, err = volumes.Create(connText, entities.VolumeCreateOptions{})
+ vol, err = volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil())
session := bt.runPodman([]string{"run", "-dt", "-v", fmt.Sprintf("%s:/foobar", vol.Name), "--name", "vtest", alpine.name, "top"})
session.Wait(45)
@@ -105,7 +105,8 @@ var _ = Describe("Podman volumes", func() {
zero := uint(0)
err = containers.Stop(connText, "vtest", &zero)
Expect(err).To(BeNil())
- err = volumes.Remove(connText, vol.Name, bindings.PTrue)
+ options := new(volumes.RemoveOptions).WithForce(true)
+ err = volumes.Remove(connText, vol.Name, options)
Expect(err).To(BeNil())
})
@@ -118,7 +119,7 @@ var _ = Describe("Podman volumes", func() {
// create a bunch of named volumes and make verify with list
volNames := []string{"homer", "bart", "lisa", "maggie", "marge"}
for i := 0; i < 5; i++ {
- _, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: volNames[i]})
+ _, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: volNames[i]}, nil)
Expect(err).To(BeNil())
}
vols, err = volumes.List(connText, nil)
@@ -131,14 +132,16 @@ var _ = Describe("Podman volumes", func() {
// list with bad filter should be 500
filters := make(map[string][]string)
filters["foobar"] = []string{"1234"}
- _, err = volumes.List(connText, filters)
+ options := new(volumes.ListOptions).WithFilters(filters)
+ _, err = volumes.List(connText, options)
Expect(err).ToNot(BeNil())
code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
filters = make(map[string][]string)
filters["name"] = []string{"homer"}
- vols, err = volumes.List(connText, filters)
+ options = new(volumes.ListOptions).WithFilters(filters)
+ vols, err = volumes.List(connText, options)
Expect(err).To(BeNil())
Expect(len(vols)).To(BeNumerically("==", 1))
Expect(vols[0].Name).To(Equal("homer"))
@@ -150,22 +153,22 @@ var _ = Describe("Podman volumes", func() {
Expect(err).To(BeNil())
// Removing an unused volume should work
- _, err = volumes.Create(connText, entities.VolumeCreateOptions{})
+ _, err = volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil())
vols, err := volumes.Prune(connText, nil)
Expect(err).To(BeNil())
Expect(len(vols)).To(BeNumerically("==", 1))
- _, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: "homer"})
+ _, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: "homer"}, nil)
Expect(err).To(BeNil())
- _, err = volumes.Create(connText, entities.VolumeCreateOptions{})
+ _, err = volumes.Create(connText, entities.VolumeCreateOptions{}, nil)
Expect(err).To(BeNil())
session := bt.runPodman([]string{"run", "-dt", "-v", fmt.Sprintf("%s:/homer", "homer"), "--name", "vtest", alpine.name, "top"})
session.Wait(45)
vols, err = volumes.Prune(connText, nil)
Expect(err).To(BeNil())
Expect(len(vols)).To(BeNumerically("==", 1))
- _, err = volumes.Inspect(connText, "homer")
+ _, err = volumes.Inspect(connText, "homer", nil)
Expect(err).To(BeNil())
// Removing volume with non matching filter shouldn't prune any volumes
@@ -173,24 +176,26 @@ var _ = Describe("Podman volumes", func() {
filters["label"] = []string{"label1=idontmatch"}
_, err = volumes.Create(connText, entities.VolumeCreateOptions{Label: map[string]string{
"label1": "value1",
- }})
+ }}, nil)
Expect(err).To(BeNil())
- vols, err = volumes.Prune(connText, filters)
+ options := new(volumes.PruneOptions).WithFilters(filters)
+ vols, err = volumes.Prune(connText, options)
Expect(err).To(BeNil())
Expect(len(vols)).To(BeNumerically("==", 0))
vol2, err := volumes.Create(connText, entities.VolumeCreateOptions{Label: map[string]string{
"label1": "value2",
- }})
+ }}, nil)
Expect(err).To(BeNil())
_, err = volumes.Create(connText, entities.VolumeCreateOptions{Label: map[string]string{
"label1": "value3",
- }})
+ }}, nil)
Expect(err).To(BeNil())
// Removing volume with matching filter label and value should remove specific entry
filters = make(map[string][]string)
filters["label"] = []string{"label1=value2"}
- vols, err = volumes.Prune(connText, filters)
+ options = new(volumes.PruneOptions).WithFilters(filters)
+ vols, err = volumes.Prune(connText, options)
Expect(err).To(BeNil())
Expect(len(vols)).To(BeNumerically("==", 1))
Expect(vols[0].Id).To(Equal(vol2.Name))
@@ -198,7 +203,8 @@ var _ = Describe("Podman volumes", func() {
// Removing volumes with matching filter label should remove all matching volumes
filters = make(map[string][]string)
filters["label"] = []string{"label1"}
- vols, err = volumes.Prune(connText, filters)
+ options = new(volumes.PruneOptions).WithFilters(filters)
+ vols, err = volumes.Prune(connText, options)
Expect(err).To(BeNil())
Expect(len(vols)).To(BeNumerically("==", 2))
})