From 20fa1228206a0180caa259f78e68d9fcf853449f Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 21 Mar 2023 18:02:12 +0100 Subject: [PATCH] test/system: Test 'list' both with and without --images https://github.com/containers/toolbox/pull/1278 --- test/system/102-list.bats | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/test/system/102-list.bats b/test/system/102-list.bats index ac119ee..6a2aec1 100644 --- a/test/system/102-list.bats +++ b/test/system/102-list.bats @@ -68,6 +68,20 @@ teardown() { assert [ ${#stderr_lines[@]} -eq 0 ] } +@test "list: With just one non-Toolbx image (using --images)" { + pull_distro_image busybox + + local num_of_images + num_of_images="$(list_images)" + assert_equal "$num_of_images" 1 + + run --keep-empty-lines --separate-stderr $TOOLBOX list --images + + assert_success + assert [ ${#lines[@]} -eq 0 ] + assert [ ${#stderr_lines[@]} -eq 0 ] +} + @test "list: An image without a name" { build_image_without_name >/dev/null @@ -79,6 +93,21 @@ teardown() { assert [ ${#stderr_lines[@]} -eq 0 ] } +@test "list: An image without a name (using --images)" { + build_image_without_name >/dev/null + + local num_of_images + num_of_images="$(list_images)" + assert_equal "$num_of_images" 1 + + run --keep-empty-lines --separate-stderr $TOOLBOX list --images + + assert_success + assert_line --index 1 --partial "" + assert [ ${#lines[@]} -eq 3 ] + assert [ ${#stderr_lines[@]} -eq 0 ] +} + @test "list: Image and its copy" { local default_image default_image="$(get_default_image)" @@ -98,6 +127,25 @@ teardown() { assert [ ${#stderr_lines[@]} -eq 0 ] } +@test "list: Image and its copy (using --images)" { + local default_image + default_image="$(get_default_image)" + + pull_default_image_and_copy + + local num_of_images + num_of_images="$(list_images)" + assert_equal "$num_of_images" 2 + + run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images + + assert_success + assert_line --index 1 --partial "$default_image" + assert_line --index 2 --partial "$default_image-copy" + assert [ ${#lines[@]} -eq 4 ] + assert [ ${#stderr_lines[@]} -eq 0 ] +} + @test "list: Containers and images" { # Pull the two images pull_default_image @@ -140,6 +188,28 @@ teardown() { assert [ ${#stderr_lines[@]} -eq 0 ] } +@test "list: Images with and without names" { + local default_image + default_image="$(get_default_image)" + + pull_default_image + pull_distro_image fedora 34 + build_image_without_name >/dev/null + + local num_of_images + num_of_images="$(list_images)" + assert_equal "$num_of_images" 3 + + run --keep-empty-lines --separate-stderr "$TOOLBOX" list + + assert_success + assert_line --index 1 --partial "" + assert_line --index 2 --partial "fedora-toolbox:34" + assert_line --index 3 --partial "$default_image" + assert [ ${#lines[@]} -eq 5 ] + assert [ ${#stderr_lines[@]} -eq 0 ] +} + @test "list: Images with and without names (using --images)" { local default_image default_image="$(get_default_image)"