#!/usr/bin/env bats -*- bats -*- # # tests for podman healthcheck # # load helpers # Helper function: run 'podman inspect' and check various given fields function _check_health { local testname="$1" local tests="$2" run_podman inspect --format json healthcheck_c parse_table "$tests" | while read field expect;do # (kludge to deal with parse_table and empty strings) if [ "$expect" = "''" ]; then expect=""; fi actual=$(jq -r ".[0].State.Healthcheck.$field" <<<"$output") is "$actual" "$expect" "$testname - .State.Healthcheck.$field" done } @test "podman healthcheck" { # Create an image with a healthcheck script; said script will # pass until the file /uh-oh gets created (by us, via exec) cat >${PODMAN_TMPDIR}/healthcheck <&2 exit 1 else echo "Life is Good on stdout" echo "Life is Good on stderr" >&2 exit 0 fi EOF cat >${PODMAN_TMPDIR}/entrypoint <${PODMAN_TMPDIR}/Containerfile <