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
This commit is contained in:
Debarshi Ray 2022-12-07 19:51:15 +01:00
parent 54f09ae8a6
commit cc60bc6893
2 changed files with 16 additions and 11 deletions

View file

@ -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 "<none>"
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)" {

View file

@ -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.