From 22c8270135620bbbeb988076378173e452ec04af Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Sat, 3 Oct 2020 06:56:42 -0400 Subject: fix podman container exists and diff for storage containers Current these commands only check if a container exists in libpod. With this fix, the commands will also check if they are in containers/storage. This allows users to look at differences within a buildah or CRI-O container. Currently buildah diff does not exists, so this helps out in that situation as well as in CRI-O since the cri does not implement a diff command. Signed-off-by: Daniel J Walsh --- test/system/030-run.bats | 17 +++++++++++++++++ test/system/140-diff.bats | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'test') diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 28dc7c7a7..a82743c70 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -460,4 +460,21 @@ json-file | f is "$output" "$expect" "podman run with --tz=local, matches host" } +@test "podman container exists" { + rand=$(random_string 30) + run_podman 1 container exists myctr + + run_podman create --name myctr $IMAGE /bin/true + run_podman container exists myctr + + # Create a container that podman does not know about + run buildah from $IMAGE + cid="$output" + + # exists should succeed + run_podman container exists $cid + + run buildah rm $cid +} + # vim: filetype=sh diff --git a/test/system/140-diff.bats b/test/system/140-diff.bats index 01ec5430e..d0f33e438 100644 --- a/test/system/140-diff.bats +++ b/test/system/140-diff.bats @@ -32,4 +32,26 @@ load helpers run_podman rm $n } +@test "podman diff with buildah container " { + rand_file=$(random_string 10) + run buildah from --name buildahctr $IMAGE + run 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 + + run buildah rm buildahctr +} + # vim: filetype=sh -- cgit v1.2.3-54-g00ecf