Files
podman/test/system/140-diff.bats
Ed Santiago b23d430516 System tests: remove some misleading 'run's
The BATS 'run' directive is really quite obnoxious; for the
most part we really don't want to use it. Remove some uses
that snuck in last week, and remove one test (exists) that
can more naturally be piggybacked into an rm test.

While we're at it: in setup(), look for and delete stray
external (buildah) containers. This will be important if
any of the external-container tests fails; this way we
don't leave behind a state that causes subsequent tests
to fail.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-19 08:43:56 -06:00

58 lines
1.3 KiB
Bash

#!/usr/bin/env bats -*- bats -*-
#
# Tests for podman diff
#
load helpers
@test "podman diff" {
n=$(random_string 10) # container name
rand_file=$(random_string 10)
run_podman run --name $n $IMAGE sh -c "touch /$rand_file;rm /etc/services"
# If running local, test `-l` (latest) option. This can't work with remote.
if ! is_remote; then
n=-l
fi
run_podman diff --format json $n
# Expected results for each type of diff
declare -A expect=(
[added]="/$rand_file"
[changed]="/etc"
[deleted]="/etc/services"
)
for field in ${!expect[@]}; do
result=$(jq -r -c ".${field}[]" <<<"$output")
is "$result" "${expect[$field]}" "$field"
done
run_podman rm $n
}
@test "podman diff with buildah container " {
rand_file=$(random_string 10)
buildah from --name buildahctr $IMAGE
buildah run buildahctr sh -c "touch /$rand_file;rm /etc/services"
run_podman diff --format json buildahctr
# Expected results for each type of diff
declare -A expect=(
[added]="/$rand_file"
[changed]="/etc"
[deleted]="/etc/services"
)
for field in ${!expect[@]}; do
result=$(jq -r -c ".${field}[]" <<<"$output")
is "$result" "${expect[$field]}" "$field"
done
buildah rm buildahctr
}
# vim: filetype=sh