2020-07-27 13:35:17 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load 'libs/bats-support/load'
|
|
|
|
load 'libs/bats-assert/load'
|
|
|
|
load 'libs/helpers'
|
|
|
|
|
|
|
|
setup() {
|
2021-11-11 00:46:21 +00:00
|
|
|
_setup_environment
|
2020-07-27 13:35:17 +00:00
|
|
|
cleanup_all
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
cleanup_all
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "list: Run 'list' with zero containers and zero images (the list should be empty)" {
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX list
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert_output ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "list: Run 'list -c' with zero containers (the list should be empty)" {
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX list -c
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert_output ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "list: Run 'list -i' with zero images (the list should be empty)" {
|
2021-09-10 03:45:10 +00:00
|
|
|
run $TOOLBOX list -i
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert_output ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "list: Run 'list' with zero toolbox's containers and images, but other image (the list should be empty)" {
|
2021-05-25 22:09:53 +00:00
|
|
|
pull_distro_image busybox
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
run podman images
|
|
|
|
|
|
|
|
assert_output --partial "$BUSYBOX_IMAGE"
|
|
|
|
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX list
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert_output ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@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)" {
|
|
|
|
# Pull the two images
|
|
|
|
pull_default_image
|
2021-05-25 22:09:53 +00:00
|
|
|
pull_distro_image fedora 32
|
|
|
|
|
|
|
|
# Create three containers
|
2020-07-27 13:35:17 +00:00
|
|
|
create_default_container
|
|
|
|
create_container non-default-one
|
|
|
|
create_container non-default-two
|
|
|
|
|
|
|
|
# Check images
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX list --images
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
2021-05-25 22:09:53 +00:00
|
|
|
assert_output --partial "$(get_system_id)-toolbox:$(get_system_version)"
|
2021-05-26 22:13:18 +00:00
|
|
|
assert_output --partial "fedora-toolbox:32"
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
# Check containers
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX list --containers
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
2021-05-25 22:09:53 +00:00
|
|
|
assert_output --partial "$(get_system_id)-toolbox-$(get_system_version)"
|
2020-07-27 13:35:17 +00:00
|
|
|
assert_output --partial "non-default-one"
|
|
|
|
assert_output --partial "non-default-two"
|
|
|
|
|
|
|
|
# Check all together
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX list
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
2021-05-25 22:09:53 +00:00
|
|
|
assert_output --partial "$(get_system_id)-toolbox:$(get_system_version)"
|
2021-05-26 22:13:18 +00:00
|
|
|
assert_output --partial "fedora-toolbox:32"
|
2021-05-25 22:09:53 +00:00
|
|
|
assert_output --partial "$(get_system_id)-toolbox-$(get_system_version)"
|
2020-07-27 13:35:17 +00:00
|
|
|
assert_output --partial "non-default-one"
|
|
|
|
assert_output --partial "non-default-two"
|
|
|
|
}
|
2021-06-22 13:47:36 +00:00
|
|
|
|
|
|
|
@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
|
2021-07-21 15:23:39 +00:00
|
|
|
assert_line --index 0 --partial "FROM scratch"
|
|
|
|
assert_line --index 1 --partial "LABEL com.github.containers.toolbox=\"true\""
|
|
|
|
assert_line --index 2 --partial "COMMIT"
|
2021-06-22 13:47:36 +00:00
|
|
|
assert_line --index 3 --regexp "^--> [a-z0-9]*$"
|
|
|
|
|
|
|
|
run $TOOLBOX list
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert_line --index 1 --partial "<none>"
|
|
|
|
|
|
|
|
rm -f "$BATS_TMPDIR"/Containerfile
|
|
|
|
}
|