diff options
Diffstat (limited to 'test/system')
-rw-r--r-- | test/system/070-build.bats | 27 | ||||
-rw-r--r-- | test/system/helpers.bash | 8 |
2 files changed, 34 insertions, 1 deletions
diff --git a/test/system/070-build.bats b/test/system/070-build.bats index 8f6cdb46b..e5b68a0d8 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -668,6 +668,33 @@ EOF run_podman image prune -f } +@test "podman build --pull-never" { + local tmpdir=$PODMAN_TMPDIR/build-test + mkdir -p $tmpdir + + # First, confirm that --pull-never is a NOP if image exists locally + local random_string=$(random_string 15) + + cat >$tmpdir/Containerfile <<EOF +FROM $IMAGE +RUN echo $random_string +EOF + + run_podman build -t build_test --pull-never $tmpdir + is "$output" ".*$random_string" "pull-never is OK if image already exists" + run_podman rmi build_test + + # Now try an image that does not exist locally nor remotely + cat >$tmpdir/Containerfile <<EOF +FROM quay.io/libpod/nosuchimage:nosuchtag +RUN echo $random_string +EOF + + run_podman 125 build -t build_test --pull-never $tmpdir + is "$output" ".* pull policy is .never. but .* could not be found locally" \ + "--pull-never fails with expected error message" +} + @test "podman build --logfile test" { tmpdir=$PODMAN_TMPDIR/build-test mkdir -p $tmpdir diff --git a/test/system/helpers.bash b/test/system/helpers.bash index 38e317709..823dc3376 100644 --- a/test/system/helpers.bash +++ b/test/system/helpers.bash @@ -72,6 +72,9 @@ function basic_setup() { # on cleanup. # TODO: do this outside of setup, so it carries across tests? PODMAN_TMPDIR=$(mktemp -d --tmpdir=${BATS_TMPDIR:-/tmp} podman_bats.XXXXXX) + + # In the unlikely event that a test runs is() before a run_podman() + MOST_RECENT_PODMAN_COMMAND= } # Basic teardown: remove all pods and containers @@ -150,6 +153,9 @@ function run_podman() { '?') expected_rc= ; shift;; # ignore exit code esac + # Remember command args, for possible use in later diagnostic messages + MOST_RECENT_PODMAN_COMMAND="podman $*" + # stdout is only emitted upon error; this echo is to help a debugger echo "$_LOG_PROMPT $PODMAN $*" # BATS hangs if a subprocess remains and keeps FD 3 open; this happens @@ -384,7 +390,7 @@ function die() { function is() { local actual="$1" local expect="$2" - local testname="${3:-FIXME}" + local testname="${3:-${MOST_RECENT_PODMAN_COMMAND:-[no test name given]}}" if [ -z "$expect" ]; then if [ -z "$actual" ]; then |