Skip to content

Commit

Permalink
Fix inspect test that rely on digest
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
umohnani8 committed Jan 25, 2024
1 parent 848078c commit 202cab6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions test/system/120-load.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 202cab6

Please sign in to comment.