2019-12-23 12:43:08 +00:00
|
|
|
#!/usr/bin/env bats -*- bats -*-
|
|
|
|
#
|
|
|
|
# Tests for podman diff
|
|
|
|
#
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
@test "podman diff" {
|
2020-07-28 14:36:52 +00:00
|
|
|
n=$(random_string 10) # container name
|
2019-12-23 12:43:08 +00:00
|
|
|
rand_file=$(random_string 10)
|
2020-07-28 14:36:52 +00:00
|
|
|
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
|
2019-12-23 12:43:08 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2020-07-28 14:36:52 +00:00
|
|
|
run_podman rm $n
|
2019-12-23 12:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# vim: filetype=sh
|