summaryrefslogtreecommitdiff
path: root/test/apiv2/test-apiv2
diff options
context:
space:
mode:
authorAlex Jia <chuanchang.jia@gmail.com>2020-05-28 09:55:12 +0000
committerAlex Jia <chuanchang.jia@gmail.com>2020-05-28 10:00:13 +0000
commit7e03d277f7a08e127190a4ffd052e91ffc077f3b (patch)
tree98dcae2b38fecfa2274d008d903bc5419614aefd /test/apiv2/test-apiv2
parentadca437d03bc74edcf3ef9b60ea55360157f893c (diff)
downloadpodman-7e03d277f7a08e127190a4ffd052e91ffc077f3b.tar.gz
podman-7e03d277f7a08e127190a4ffd052e91ffc077f3b.tar.bz2
podman-7e03d277f7a08e127190a4ffd052e91ffc077f3b.zip
test.apiv2: add testing for image and deal with API returning binary
Add testing for displaying image history and exporting image Deal with API returning binary (Content-Type =~ 'octet'). When so, set $output to the output of 'file'. Bug fix: in 't' helper, declare loop var $i as local to avoid contaminating caller Signed-off-by: Ed Santiago <santiago@redhat.com> Signed-off-by: Alex Jia <chuanchang.jia@gmail.com>
Diffstat (limited to 'test/apiv2/test-apiv2')
-rwxr-xr-xtest/apiv2/test-apiv219
1 files changed, 14 insertions, 5 deletions
diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2
index 11c914704..7a3518df2 100755
--- a/test/apiv2/test-apiv2
+++ b/test/apiv2/test-apiv2
@@ -207,13 +207,21 @@ function t() {
fi
cat $WORKDIR/curl.headers.out >>$LOG 2>/dev/null || true
- output=$(< $WORKDIR/curl.result.out)
- # Log results. If JSON, filter through jq for readability
- if egrep -qi '^Content-Type: application/json' $WORKDIR/curl.headers.out; then
- jq . <<<"$output" >>$LOG
- else
+ # Log results, if text. If JSON, filter through jq for readability.
+ content_type=$(sed -ne 's/^Content-Type:[ ]\+//pi' <$WORKDIR/curl.headers.out)
+
+ if [[ $content_type =~ /octet ]]; then
+ output="[$(file --brief $WORKDIR/curl.result.out)]"
echo "$output" >>$LOG
+ else
+ output=$(< $WORKDIR/curl.result.out)
+
+ if [[ $content_type =~ application/json ]]; then
+ jq . <<<"$output" >>$LOG
+ else
+ echo "$output" >>$LOG
+ fi
fi
# Test return code
@@ -232,6 +240,7 @@ function t() {
return
fi
+ local i
for i; do
case "$i" in
# Exact match on json field