Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/system: make list orders more flexible (fix for Ubuntu hosts) #1408

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 46 additions & 14 deletions test/system/102-list.bats
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ teardown() {

@test "list: Containers and images" {
local default_image
local fedora34image
default_image="$(get_default_image)"
fedora34image="registry.fedoraproject.org/fedora-toolbox:34"

local default_container
default_container="$(get_system_id)-toolbox-$(get_system_version)"
Expand All @@ -498,9 +500,15 @@ teardown() {
# Check images
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images

# Alphabetize images
local image1
local image2
image1="$(echo -e "$fedora34image\n$default_image" | sort | head -n 1)"
image2="$(echo -e "$fedora34image\n$default_image" | sort | tail -n 1)"

assert_success
assert_line --index 1 --partial "registry.fedoraproject.org/fedora-toolbox:34"
assert_line --index 2 --partial "$default_image"
assert_line --index 1 --partial "$image1"
assert_line --index 2 --partial "$image2"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 3 ]
Expand All @@ -513,10 +521,18 @@ teardown() {
# Check containers
run --keep-empty-lines --separate-stderr "$TOOLBOX" list --containers

# Alphabetize containers
local container1
local container2
local container3
container1="$(echo -e "$default_container\nnon-default-one\nnon-default-two" | sort | head -n 1)"
container2="$(echo -e "$default_container\nnon-default-one\nnon-default-two" | sort | head -n 2 | tail -n 1)"
container3="$(echo -e "$default_container\nnon-default-one\nnon-default-two" | sort | tail -n 1)"

assert_success
assert_line --index 1 --partial "$default_container"
assert_line --index 2 --partial "non-default-one"
assert_line --index 3 --partial "non-default-two"
assert_line --index 1 --partial "$container1"
assert_line --index 2 --partial "$container2"
assert_line --index 3 --partial "$container3"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 4 ]
Expand All @@ -530,11 +546,11 @@ teardown() {
run --keep-empty-lines --separate-stderr "$TOOLBOX" list

assert_success
assert_line --index 1 --partial "registry.fedoraproject.org/fedora-toolbox:34"
assert_line --index 2 --partial "$default_image"
assert_line --index 5 --partial "$default_container"
assert_line --index 6 --partial "non-default-one"
assert_line --index 7 --partial "non-default-two"
assert_line --index 1 --partial "$image1"
assert_line --index 2 --partial "$image2"
assert_line --index 5 --partial "$container1"
assert_line --index 6 --partial "$container2"
assert_line --index 7 --partial "$container3"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 8 ]
Expand All @@ -547,7 +563,9 @@ teardown() {

@test "list: Images with and without names" {
local default_image
local fedora34image
default_image="$(get_default_image)"
fedora34image="registry.fedoraproject.org/fedora-toolbox:34"

pull_default_image
pull_distro_image fedora 34
Expand All @@ -559,10 +577,16 @@ teardown() {

run --keep-empty-lines --separate-stderr "$TOOLBOX" list

# Alphabetize images
local image1
local image2
image1="$(echo -e "$fedora34image\n$default_image" | sort | head -n 1)"
image2="$(echo -e "$fedora34image\n$default_image" | sort | tail -n 1)"

assert_success
assert_line --index 1 --partial "<none>"
assert_line --index 2 --partial "registry.fedoraproject.org/fedora-toolbox:34"
assert_line --index 3 --partial "$default_image"
assert_line --index 2 --partial "$image1"
assert_line --index 3 --partial "$image2"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 4 ]
Expand All @@ -575,18 +599,26 @@ teardown() {

@test "list: Images with and without names (using --images)" {
local default_image
local fedora34image
default_image="$(get_default_image)"
fedora34image="registry.fedoraproject.org/fedora-toolbox:34"

pull_default_image
pull_distro_image fedora 34
build_image_without_name >/dev/null

run --keep-empty-lines --separate-stderr "$TOOLBOX" list --images

# Alphabetize images
local image1
local image2
image1="$(echo -e "$fedora34image\n$default_image" | sort | head -n 1)"
image2="$(echo -e "$fedora34image\n$default_image" | sort | tail -n 1)"

assert_success
assert_line --index 1 --partial "<none>"
assert_line --index 2 --partial "registry.fedoraproject.org/fedora-toolbox:34"
assert_line --index 3 --partial "$default_image"
assert_line --index 2 --partial "$image1"
assert_line --index 3 --partial "$image2"

if check_bats_version 1.10.0; then
assert [ ${#lines[@]} -eq 4 ]
Expand Down