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() {
|
|
|
|
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-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' 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-05-26 13:25:04 +00:00
|
|
|
|
|
|
|
@test "list: Run 'list -i' with UBI image (8.4; public) present" {
|
|
|
|
pull_distro_image rhel 8.4
|
|
|
|
|
|
|
|
run toolbox list --images
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert_output --partial "registry.access.redhat.com/ubi8/ubi:8.4"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "list: Run 'list' with UBI image (8.4; public), toolbox container and non-toolbox container" {
|
|
|
|
local num_of_containers
|
|
|
|
|
|
|
|
pull_distro_image rhel 8.4
|
|
|
|
|
|
|
|
create_distro_container rhel 8.4 rhel-toolbox
|
|
|
|
podman create --name podman-container ubi8/ubi:8.4 /bin/sh
|
|
|
|
|
|
|
|
num_of_containers=$(list_containers)
|
|
|
|
assert [ $num_of_containers -eq 2 ]
|
|
|
|
|
|
|
|
run toolbox list
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert_line --index 1 --partial "registry.access.redhat.com/ubi8/ubi:8.4"
|
|
|
|
assert_line --index 3 --partial "rhel-toolbox"
|
|
|
|
refute_output --partial "podman-container"
|
|
|
|
}
|