Fix inspect test that rely on digest

Given that we can have multiple image digests,
fix the inspect test to check whether the digest
given matches one of the digests of the image.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
This commit is contained in:
Urvashi Mohnani 2024-01-25 13:37:21 -05:00
parent 848078c938
commit 202cab6124
2 changed files with 10 additions and 6 deletions

View File

@ -629,12 +629,16 @@ json-file | f
@test "podman inspect includes image data" {
randomname=$(random_string 30)
run_podman inspect $IMAGE --format "{{.ID}} {{.Digest}}"
run_podman inspect $IMAGE --format "{{.ID}}"
expected="$IMAGE $output"
run_podman inspect $IMAGE --format "{{.RepoDigests}}"
expectedDigests="$output"
run_podman run --name $randomname $IMAGE true
run_podman container inspect $randomname --format "{{.ImageName}} {{.Image}} {{.ImageDigest}}"
run_podman container inspect $randomname --format "{{.ImageName}} {{.Image}}"
is "$output" "$expected"
run_podman container inspect $randomname --format "{{.ImageDigest}}"
assert "$output" =~ "$expectedDigests"
run_podman rm -f -t0 $randomname
}

View File

@ -109,8 +109,8 @@ verify_iid_and_name() {
_sudo true || skip "cannot sudo to $notme"
# Preserve digest of original image; we will compare against it later
run_podman image inspect --format '{{.Digest}}' $IMAGE
src_digest=$output
run_podman image inspect --format '{{.RepoDigests}}' $IMAGE
src_digests=$output
# image name that is not likely to exist in the destination
newname=foo.bar/nonesuch/c_$(random_string 10 | tr A-Z a-z):mytag
@ -132,14 +132,14 @@ verify_iid_and_name() {
# Confirm that we have it, and that its digest matches our original
run_podman image inspect --format '{{.Digest}}' $newname
is "$output" "$src_digest" "Digest of re-fetched image matches original"
assert "$output" =~ "$src_digests" "Digest of re-fetched image is in list of original image digests"
# test tagging capability
run_podman untag $IMAGE $newname
run_podman image scp ${notme}@localhost::$newname foobar:123
run_podman image inspect --format '{{.Digest}}' foobar:123
is "$output" "$src_digest" "Digest of re-fetched image matches original"
assert "$output" =~ "$src_digest" "Digest of re-fetched image is in list of original image digests"
# remove root img for transfer back with another name
_sudo $PODMAN image rm $newname