test/system: Test 'rmi' with an image without a name

https://github.com/containers/toolbox/pull/1195
This commit is contained in:
Debarshi Ray 2022-12-09 11:02:28 +01:00
parent e25ab310fa
commit a0d4c957b3
3 changed files with 32 additions and 3 deletions

View file

@ -64,7 +64,7 @@ teardown() {
} }
@test "list: List an image without a name" { @test "list: List an image without a name" {
build_image_without_name build_image_without_name >/dev/null
run --keep-empty-lines --separate-stderr $TOOLBOX list run --keep-empty-lines --separate-stderr $TOOLBOX list
@ -130,7 +130,7 @@ teardown() {
pull_default_image pull_default_image
pull_distro_image fedora 34 pull_distro_image fedora 34
build_image_without_name build_image_without_name >/dev/null
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images

View file

@ -70,7 +70,7 @@ teardown() {
num_of_images="$(list_images)" num_of_images="$(list_images)"
assert_equal "$num_of_images" 0 assert_equal "$num_of_images" 0
build_image_without_name build_image_without_name >/dev/null
num_of_images="$(list_images)" num_of_images="$(list_images)"
assert_equal "$num_of_images" 1 assert_equal "$num_of_images" 1
@ -90,6 +90,31 @@ teardown() {
assert_equal "$num_of_images" 0 assert_equal "$num_of_images" 0
} }
@test "rmi: An image without a name" {
local num_of_images
num_of_images="$(list_images)"
assert_equal "$num_of_images" 0
image="$(build_image_without_name)"
num_of_images="$(list_images)"
assert_equal "$num_of_images" 1
run --keep-empty-lines --separate-stderr "$TOOLBOX" rmi "$image"
assert_success
assert_output ""
output="$stderr"
assert_output ""
if check_bats_version 1.7.0; then
assert [ ${#lines[@]} -eq 0 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
fi
num_of_images="$(list_images)"
assert_equal "$num_of_images" 0
}
@test "rmi: Try to remove all images with a container present and running" { @test "rmi: Try to remove all images with a container present and running" {
skip "Bug: Fail in 'toolbox rmi' does not return non-zero value" skip "Bug: Fail in 'toolbox rmi' does not return non-zero value"
num_of_images=$(list_images) num_of_images=$(list_images)

View file

@ -234,8 +234,12 @@ function build_image_without_name() {
assert_line --index 1 --partial "LABEL com.github.containers.toolbox=\"true\"" assert_line --index 1 --partial "LABEL com.github.containers.toolbox=\"true\""
assert_line --index 2 --partial "COMMIT" assert_line --index 2 --partial "COMMIT"
assert_line --index 3 --regexp "^--> [a-z0-9]*$" assert_line --index 3 --regexp "^--> [a-z0-9]*$"
last=$((${#lines[@]}-1))
assert_line --index "$last" --regexp "^[a-f0-9]{64}$"
rm -f "$BATS_TMPDIR"/Containerfile rm -f "$BATS_TMPDIR"/Containerfile
echo "${lines[$last]}"
} }