aboutsummaryrefslogtreecommitdiff
path: root/test/apiv2
diff options
context:
space:
mode:
authorAlex Jia <chuanchang.jia@gmail.com>2020-06-03 05:31:28 +0000
committerAlex Jia <chuanchang.jia@gmail.com>2020-06-03 05:33:56 +0000
commit382342a0b040bd5b0522aea04cf3accc862781bd (patch)
treea1ee18783fc5f64e0d8b76cd1de37fcf7ee27c39 /test/apiv2
parent95ea39edf34e4de4450c1674721ab02a7cf6a327 (diff)
downloadpodman-382342a0b040bd5b0522aea04cf3accc862781bd.tar.gz
podman-382342a0b040bd5b0522aea04cf3accc862781bd.tar.bz2
podman-382342a0b040bd5b0522aea04cf3accc862781bd.zip
test.apiv2: add test cases for committing an image from a container
Testing query parameters: container, repo, tag, comment, author, changes and pause. Signed-off-by: Alex Jia <chuanchang.jia@gmail.com>
Diffstat (limited to 'test/apiv2')
-rw-r--r--test/apiv2/20-containers.at52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at
index 7fb39b221..8b535928a 100644
--- a/test/apiv2/20-containers.at
+++ b/test/apiv2/20-containers.at
@@ -30,4 +30,56 @@ cid=$(jq -r '.[0].Id' <<<"$output")
t DELETE libpod/containers/$cid 204
+CNAME=myfoo
+podman run --name $CNAME $IMAGE -td top
+t GET libpod/containers/json?all=true 200 \
+ .[0].Id~[0-9a-f]\\{12\\}
+cid=$(jq -r '.[0].Id' <<<"$output")
+
+# No such container
+t POST "libpod/commit?container=nonesuch" '' 404
+
+# Comment can only be used with docker format, not OCI
+cparam="repo=newrepo&comment=foo&author=bob"
+t POST "libpod/commit?container=$CNAME&$cparam" '' 500
+
+# Commit a new image from the container
+t POST "libpod/commit?container=$CNAME" '' 200 \
+ .Id~[0-9a-f]\\{12\\}
+iid=$(jq -r '.Id' <<<"$output")
+t GET libpod/images/$iid/json 200 \
+ .RepoTags[0]=null \
+ .Author="" \
+ .Comment=""
+
+# Commit a new image w/o tag
+cparam="repo=newrepo&comment=foo&author=bob&format=docker"
+t POST "libpod/commit?container=$CNAME&$cparam" '' 200
+t GET libpod/images/newrepo:latest/json 200 \
+ .RepoTags[0]=localhost/newrepo:latest \
+ .Author=bob \
+ .Comment=foo
+
+# Commit a new image w/ specified tag and author
+cparam="repo=newrepo&tag=v1&author=alice"
+t POST "libpod/commit?container=$cid&$cparam&pause=false" '' 200
+t GET libpod/images/newrepo:v1/json 200 \
+ .RepoTags[0]=localhost/newrepo:v1 \
+ .Author=alice
+
+# Commit a new image w/ full parameters
+cparam="repo=newrepo&tag=v2&comment=bar&author=eric"
+cparam="$cparam&format=docker&changes=CMD=/bin/foo"
+t POST "libpod/commit?container=${cid:0:12}&$cparam&pause=true" '' 200
+t GET libpod/images/newrepo:v2/json 200 \
+ .RepoTags[0]=localhost/newrepo:v2 \
+ .Author=eric \
+ .Comment=bar \
+ .Config.Cmd[-1]="/bin/foo"
+
+t DELETE images/localhost/newrepo:latest?force=true 200
+t DELETE images/localhost/newrepo:v1?force=true 200
+t DELETE images/localhost/newrepo:v2?force=true 200
+t DELETE libpod/containers/$cid 204
+
# vim: filetype=sh