2020-07-27 13:35:17 +00:00
|
|
|
|
#!/usr/bin/env bats
|
2022-11-29 12:54:13 +00:00
|
|
|
|
#
|
|
|
|
|
# Copyright © 2019 – 2022 Red Hat, Inc.
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
#
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
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)" {
|
2022-12-07 14:22:04 +00:00
|
|
|
|
run --keep-empty-lines $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)" {
|
2022-12-07 14:22:04 +00:00
|
|
|
|
run --keep-empty-lines $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)" {
|
2022-12-07 14:22:04 +00:00
|
|
|
|
run --keep-empty-lines $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"
|
|
|
|
|
|
2022-12-07 14:22:04 +00:00
|
|
|
|
run --keep-empty-lines $TOOLBOX list
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_output ""
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 18:21:31 +00:00
|
|
|
|
@test "list: List an image without a name" {
|
2022-12-07 18:51:15 +00:00
|
|
|
|
build_image_without_name
|
2022-12-07 18:21:31 +00:00
|
|
|
|
|
2022-12-07 20:02:17 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list
|
2022-12-07 18:21:31 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "<none>"
|
2022-12-07 20:16:46 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 3 ]
|
|
|
|
|
if check_bats_version 1.7.0; then
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
fi
|
2022-12-07 18:21:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-27 13:35:17 +00:00
|
|
|
|
@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
|
2022-12-05 19:54:51 +00:00
|
|
|
|
pull_distro_image fedora 34
|
2021-05-25 22:09:53 +00:00
|
|
|
|
|
|
|
|
|
# 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
|
2022-12-07 20:02:17 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --images
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2022-12-07 12:34:38 +00:00
|
|
|
|
assert_line --index 1 --partial "$(get_system_id)-toolbox:$(get_system_version)"
|
|
|
|
|
assert_line --index 2 --partial "fedora-toolbox:34"
|
2022-12-07 20:16:46 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 4 ]
|
|
|
|
|
if check_bats_version 1.7.0; then
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
fi
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
# Check containers
|
2022-12-07 20:02:17 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list --containers
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2022-12-07 12:34:38 +00:00
|
|
|
|
assert_line --index 1 --partial "$(get_system_id)-toolbox-$(get_system_version)"
|
|
|
|
|
assert_line --index 2 --partial "non-default-one"
|
|
|
|
|
assert_line --index 3 --partial "non-default-two"
|
2022-12-07 20:16:46 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 5 ]
|
|
|
|
|
if check_bats_version 1.7.0; then
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
fi
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
# Check all together
|
2022-12-07 20:02:17 +00:00
|
|
|
|
run --keep-empty-lines --separate-stderr $TOOLBOX list
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2022-12-07 12:34:38 +00:00
|
|
|
|
assert_line --index 1 --partial "$(get_system_id)-toolbox:$(get_system_version)"
|
|
|
|
|
assert_line --index 2 --partial "fedora-toolbox:34"
|
2022-12-07 14:22:04 +00:00
|
|
|
|
assert_line --index 5 --partial "$(get_system_id)-toolbox-$(get_system_version)"
|
|
|
|
|
assert_line --index 6 --partial "non-default-one"
|
|
|
|
|
assert_line --index 7 --partial "non-default-two"
|
2022-12-07 20:16:46 +00:00
|
|
|
|
assert [ ${#lines[@]} -eq 9 ]
|
|
|
|
|
if check_bats_version 1.7.0; then
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
fi
|
2020-07-27 13:35:17 +00:00
|
|
|
|
}
|
2022-12-07 18:52:50 +00:00
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
|
|
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_line --index 1 --partial "<none>"
|
|
|
|
|
assert_line --index 2 --partial "$default_image"
|
|
|
|
|
assert_line --index 3 --partial "fedora-toolbox:34"
|
|
|
|
|
assert [ ${#lines[@]} -eq 5 ]
|
|
|
|
|
if check_bats_version 1.7.0; then
|
|
|
|
|
assert [ ${#stderr_lines[@]} -eq 0 ]
|
|
|
|
|
fi
|
|
|
|
|
}
|