From cc60bc68936dcbdca1d08635fdcdf9fb50301358 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Wed, 7 Dec 2022 19:51:15 +0100 Subject: [PATCH] test/system: Split out the code to build an image without a name This will be used by a subsequent commit to test the order in which images with and without names are listed. https://github.com/containers/toolbox/pull/1192 --- test/system/102-list.bats | 12 +----------- test/system/libs/helpers.bash | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/test/system/102-list.bats b/test/system/102-list.bats index 584c8d1..3a98778 100644 --- a/test/system/102-list.bats +++ b/test/system/102-list.bats @@ -64,22 +64,12 @@ teardown() { } @test "list: List an image without a name" { - echo -e "FROM scratch\n\nLABEL com.github.containers.toolbox=\"true\"" > "$BATS_TMPDIR"/Containerfile - - run $PODMAN build "$BATS_TMPDIR" - - assert_success - assert_line --index 0 --partial "FROM scratch" - assert_line --index 1 --partial "LABEL com.github.containers.toolbox=\"true\"" - assert_line --index 2 --partial "COMMIT" - assert_line --index 3 --regexp "^--> [a-z0-9]*$" + build_image_without_name run --keep-empty-lines $TOOLBOX list assert_success assert_line --index 1 --partial "" - - rm -f "$BATS_TMPDIR"/Containerfile } @test "list: Try to list images and containers (no flag) with 3 containers and 2 images (the list should have 3 images and 2 containers)" { diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 3b4174b..f223cee 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -224,6 +224,21 @@ function _clean_docker_registry() { } +function build_image_without_name() { + echo -e "FROM scratch\n\nLABEL com.github.containers.toolbox=\"true\"" > "$BATS_TMPDIR"/Containerfile + + run $PODMAN build "$BATS_TMPDIR" + + assert_success + assert_line --index 0 --partial "FROM scratch" + assert_line --index 1 --partial "LABEL com.github.containers.toolbox=\"true\"" + assert_line --index 2 --partial "COMMIT" + assert_line --index 3 --regexp "^--> [a-z0-9]*$" + + rm -f "$BATS_TMPDIR"/Containerfile +} + + # Copies an image from local storage to Podman's image store # # Call before creating any container. Network failures are not nice.