diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2021-12-15 14:41:47 +0100 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2021-12-16 15:31:29 +0100 |
commit | f241efb17993a3234008ed95e899ad1ae849fca0 (patch) | |
tree | 4ddca05b1e82e2edb548418a7000794a7574fc0c /pkg/bindings/test/images_test.go | |
parent | d984fec351c06a95f8a51c7e6ced819c6b17245f (diff) | |
download | podman-f241efb17993a3234008ed95e899ad1ae849fca0.tar.gz podman-f241efb17993a3234008ed95e899ad1ae849fca0.tar.bz2 podman-f241efb17993a3234008ed95e899ad1ae849fca0.zip |
bindings rmi test: clarify behavior
The libpod/images/remove endpoint is not very REST-ish but, after some
debate, was decided to be implemented as for the following reasons.
First, it allows for batch removing images which improves performance
significantly. Note that Docker does support `rmi -a`!
Second, it allows for hiding the logic of setting the right exit code to
use from the client and keep all the logic on the server.
Hence, when removing an image that does not exist, the server will
return a 200. The response, however, includes the error message to be
used *and* the exit code that podman-remote will use.
Fixes: #12441
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/bindings/test/images_test.go')
-rw-r--r-- | pkg/bindings/test/images_test.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/pkg/bindings/test/images_test.go b/pkg/bindings/test/images_test.go index 8489e6ff1..4ee824472 100644 --- a/pkg/bindings/test/images_test.go +++ b/pkg/bindings/test/images_test.go @@ -85,14 +85,16 @@ var _ = Describe("Podman images", func() { // Test to validate the remove image api It("remove image", func() { - // Remove invalid image should be a 404 + // NOTE that removing an image that does not exist will still + // return a 200 http status. The response, however, includes + // the exit code that podman-remote should exit with. + // + // The libpod/images/remove endpoint supports batch removal of + // images for performance reasons and for hiding the logic of + // deciding which exit code to use from the client. response, errs := images.Remove(bt.conn, []string{"foobar5000"}, nil) Expect(len(errs)).To(BeNumerically(">", 0)) - code, _ := bindings.CheckResponseCode(errs[0]) - // FIXME FIXME FIXME: #12441: THIS IS BROKEN - // FIXME FIXME FIXME: we get msg: "foobar5000: image not known" - // FIXME FIXME FIXME: ...with no ResponseCode - Expect(code).To(BeNumerically("==", -1)) + Expect(response.ExitCode).To(BeNumerically("==", 1)) // podman-remote would exit with 1 // Remove an image by name, validate image is removed and error is nil inspectData, err := images.GetImage(bt.conn, busybox.shortName, nil) @@ -102,7 +104,7 @@ var _ = Describe("Podman images", func() { Expect(inspectData.ID).To(Equal(response.Deleted[0])) inspectData, err = images.GetImage(bt.conn, busybox.shortName, nil) - code, _ = bindings.CheckResponseCode(err) + code, _ := bindings.CheckResponseCode(err) Expect(code).To(BeNumerically("==", http.StatusNotFound)) // Start a container with alpine image |