diff options
author | Ed Santiago <santiago@redhat.com> | 2019-02-20 13:19:20 -0700 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2019-03-07 13:09:54 -0700 |
commit | 681eae9bcc856f8dad107765a97c29d0fe093d4a (patch) | |
tree | a8224181c5b01ebfece7e309117b9bc1d4e5a9a0 /test/system/110-history.bats | |
parent | 1b253cf73a360557196213684cec63b37407ed7c (diff) | |
download | podman-681eae9bcc856f8dad107765a97c29d0fe093d4a.tar.gz podman-681eae9bcc856f8dad107765a97c29d0fe093d4a.tar.bz2 podman-681eae9bcc856f8dad107765a97c29d0fe093d4a.zip |
new system tests under BATS
Initial attempt at writing a framework for podman system tests.
The idea is to define a useful set of primitives that will
make it easy to write actual tests and to interpret results
of failing ones.
This is a proof-of-concept right now; only a small number of
tests, by no means comprehensive. I am requesting review in
order to find showstopper problems: reasons why this approach
cannot work. Should there be none, we can work toward running
these as gating tests for Fedora and RHEL8.
Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/system/110-history.bats')
-rw-r--r-- | test/system/110-history.bats | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/system/110-history.bats b/test/system/110-history.bats new file mode 100644 index 000000000..c00949bd1 --- /dev/null +++ b/test/system/110-history.bats @@ -0,0 +1,49 @@ +#!/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" + + run_podman history "$@" $PODMAN_TEST_IMAGE_FQN + is "$output" "$expect" "podman history $options" + done +} + +@test "podman history - json" { + type -path jq >/dev/null || die "FAIL: please 'dnf -y install jq'" + + tests=" +id | [0-9a-f]\\\{64\\\} +created | [0-9-]\\\+T[0-9:]\\\+\\\.[0-9]\\\+Z +size | -\\\?[0-9]\\\+ +" + + run_podman history --format json $PODMAN_TEST_IMAGE_FQN + + 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 + +} |