mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Updated system test to be easier to read
Following @edsantiago guidance, * Additional explanations for each step of the test * Timezone for tests normalized to UTC * Smarter choice of separator and use of shell substring extraction Signed-off-by: rbagd <mail@rbagd.eu>
This commit is contained in:
@ -57,26 +57,30 @@ size | -\\\?[0-9]\\\+
|
|||||||
|
|
||||||
@test "podman image history Created" {
|
@test "podman image history Created" {
|
||||||
# Values from image LIST
|
# Values from image LIST
|
||||||
run_podman image list --format '{{.CreatedSince}};{{.CreatedAt}}' $IMAGE
|
run_podman image list --format '{{.CreatedSince}}\n{{.CreatedAt}}' $IMAGE
|
||||||
from_imagelist="$output"
|
imagelist_since="${lines[0]}"
|
||||||
assert "$from_imagelist" =~ "^[0-9].* ago;[0-9]+-[0-9]+-[0-9]+ [0-9:]+ " \
|
imagelist_at="${lines[1]}"
|
||||||
"CreatedSince and CreatedAt look reasonable"
|
|
||||||
|
|
||||||
# Values from image HISTORY
|
assert "${imagelist_since}" =~ "^[0-9]+.* ago" \
|
||||||
run_podman image history --format '{{.CreatedSince}};{{.CreatedAt}}' $IMAGE
|
"image list: CreatedSince looks reasonable"
|
||||||
from_imagehistory="${lines[0]}"
|
assert "${imagelist_at}" =~ "^[0-9]+-[0-9]+-[0-9]+ [0-9:]+ \+0000 UTC\$" \
|
||||||
|
"image list: CreatedAt looks reasonable"
|
||||||
|
|
||||||
imagelist_since=$(echo "$from_imagelist" | cut -d';' -f1)
|
# Values from image HISTORY. For docker compatibility, this command now
|
||||||
imagehist_since=$(echo "$from_imagehistory" | cut -d';' -f1)
|
# honors $TZ (#18213) for CreatedAt.
|
||||||
|
TZ=UTC run_podman image history --format '{{.CreatedSince}}\n{{.CreatedAt}}' $IMAGE
|
||||||
|
imagehistory_since="${lines[0]}"
|
||||||
|
imagehistory_at="${lines[1]}"
|
||||||
|
|
||||||
assert "$imagehist_since" == "$imagelist_since" \
|
assert "$imagehistory_since" == "$imagelist_since" \
|
||||||
"CreatedSince from image history should == image list"
|
"CreatedSince from image history should == image list"
|
||||||
|
|
||||||
imagelist_at=$(date --rfc-3339=seconds -f <(echo "$from_imagelist" | cut -d';' -f2 | sed 's/ UTC//'))
|
# More docker compatibility: both commands emit ISO8601-ish dates but
|
||||||
imagehist_at=$(date --rfc-3339=seconds -f <(echo "$from_imagehistory" | cut -d';' -f2))
|
# with different separators so we need to compare date & time separately.
|
||||||
|
assert "${imagehistory_at:0:10}" == "${imagelist_at:0:10}" \
|
||||||
assert "$imagehist_at" == "$imagelist_at" \
|
"CreatedAt (date) from image history should == image list"
|
||||||
"CreatedAt from image history should == image list"
|
assert "${imagehistory_at:11:8}" == "${imagelist_at:11:8}" \
|
||||||
|
"CreatedAt (time) from image history should == image list"
|
||||||
}
|
}
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
Reference in New Issue
Block a user