2019-02-20 20:19:20 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
@test "podman history - basic tests" {
|
|
|
|
tests="
|
|
|
|
| .*[0-9a-f]\\\{12\\\} .* CMD .* LABEL
|
|
|
|
--format '{{.ID}} {{.Created}}' | .*[0-9a-f]\\\{12\\\} .* ago
|
|
|
|
--human=false | .*[0-9a-f]\\\{12\\\} *[0-9-]\\\+T[0-9:]\\\+Z
|
|
|
|
-qH | .*[0-9a-f]\\\{12\\\}
|
|
|
|
--no-trunc | .*[0-9a-f]\\\{64\\\}
|
|
|
|
"
|
|
|
|
|
|
|
|
parse_table "$tests" | while read options expect; do
|
|
|
|
if [ "$options" = "''" ]; then options=; fi
|
|
|
|
|
|
|
|
eval set -- "$options"
|
|
|
|
|
2019-03-05 16:58:30 +00:00
|
|
|
run_podman history "$@" $IMAGE
|
2019-02-20 20:19:20 +00:00
|
|
|
is "$output" "$expect" "podman history $options"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "podman history - json" {
|
|
|
|
tests="
|
|
|
|
id | [0-9a-f]\\\{64\\\}
|
2019-04-10 14:17:03 +00:00
|
|
|
created | [0-9-]\\\+T[0-9:.]\\\+Z
|
2019-02-20 20:19:20 +00:00
|
|
|
size | -\\\?[0-9]\\\+
|
|
|
|
"
|
|
|
|
|
2019-03-05 16:58:30 +00:00
|
|
|
run_podman history --format json $IMAGE
|
2019-02-20 20:19:20 +00:00
|
|
|
|
|
|
|
parse_table "$tests" | while read field expect; do
|
|
|
|
# HACK: we can't include '|' in the table
|
|
|
|
if [ "$field" = "id" ]; then expect="$expect\|<missing>";fi
|
|
|
|
|
|
|
|
# output is an array of dicts; check each one
|
|
|
|
count=$(echo "$output" | jq '. | length')
|
|
|
|
i=0
|
|
|
|
while [ $i -lt $count ]; do
|
|
|
|
actual=$(echo "$output" | jq -r ".[$i].$field")
|
|
|
|
is "$actual" "$expect\$" "jq .[$i].$field"
|
|
|
|
i=$(expr $i + 1)
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
2019-03-05 16:58:30 +00:00
|
|
|
|
|
|
|
# vim: filetype=sh
|