Skip to content

Commit

Permalink
test/system: make list orders more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
pennbauman committed Nov 17, 2023
1 parent f28ad77 commit 94bacc5
Showing 1 changed file with 46 additions and 14 deletions.
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="$(printf "$fedora34image\n$default_image" | sort | head -n 1)"
image2="$(printf "$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="$(printf "$default_container\nnon-default-one\nnon-default-two" | sort | head -n 1)"
container2="$(printf "$default_container\nnon-default-one\nnon-default-two" | sort | head -n 2 | tail -n 1)"
container3="$(printf "$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="$(printf "$fedora34image\n$default_image" | sort | head -n 1)"
image2="$(printf "$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="$(printf "$fedora34image\n$default_image" | sort | head -n 1)"
image2="$(printf "$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

0 comments on commit 94bacc5

Please sign in to comment.