Skip to content

Commit

Permalink
test/system: Simplify the line count checks by relying on Bats >= 1.7.0
Browse files Browse the repository at this point in the history
Fedora 35 was stuck with Bats 1.5.0.  However, it reached End of Life on
13th December 2022 and was dropped from the CI [1].  Fedora 36 is the
oldest supported Fedora and it has Bats 1.8.2.

Therefore, there's no need to retain compatibility with Bats < 1.7.0.

Note that bats_require_minimum_version itself is only available from
Bats 1.7.0 [2].

[1] Commit 419e4e8
    containers#1237

[2] Bats commit 71d6b71cebc3d32b
    bats-core/bats-core#556
    https://bats-core.readthedocs.io/en/stable/warnings/BW02.html

containers#1273
  • Loading branch information
debarshiray committed Mar 21, 2023
1 parent db1a265 commit 3c50af3
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions test/system/102-list.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ load 'libs/bats-assert/load'
load 'libs/helpers'

setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_all
}
Expand Down Expand Up @@ -71,9 +72,7 @@ teardown() {
assert_success
assert_line --index 1 --partial "<none>"
assert [ ${#lines[@]} -eq 3 ]
if check_bats_version 1.7.0; then
assert [ ${#stderr_lines[@]} -eq 0 ]
fi
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "list: Image and its copy" {
Expand All @@ -92,9 +91,7 @@ teardown() {
assert_line --index 1 --partial "$default_image"
assert_line --index 2 --partial "$default_image-copy"
assert [ ${#lines[@]} -eq 4 ]
if check_bats_version 1.7.0; then
assert [ ${#stderr_lines[@]} -eq 0 ]
fi
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "list: Containers and images" {
Expand All @@ -114,9 +111,7 @@ teardown() {
assert_line --index 1 --partial "fedora-toolbox:34"
assert_line --index 2 --partial "$(get_system_id)-toolbox:$(get_system_version)"
assert [ ${#lines[@]} -eq 4 ]
if check_bats_version 1.7.0; then
assert [ ${#stderr_lines[@]} -eq 0 ]
fi
assert [ ${#stderr_lines[@]} -eq 0 ]

# Check containers
run --keep-empty-lines --separate-stderr $TOOLBOX list --containers
Expand All @@ -126,9 +121,7 @@ teardown() {
assert_line --index 2 --partial "non-default-one"
assert_line --index 3 --partial "non-default-two"
assert [ ${#lines[@]} -eq 5 ]
if check_bats_version 1.7.0; then
assert [ ${#stderr_lines[@]} -eq 0 ]
fi
assert [ ${#stderr_lines[@]} -eq 0 ]

# Check all together
run --keep-empty-lines --separate-stderr $TOOLBOX list
Expand All @@ -140,9 +133,7 @@ teardown() {
assert_line --index 6 --partial "non-default-one"
assert_line --index 7 --partial "non-default-two"
assert [ ${#lines[@]} -eq 9 ]
if check_bats_version 1.7.0; then
assert [ ${#stderr_lines[@]} -eq 0 ]
fi
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "list: Images with and without names" {
Expand All @@ -160,7 +151,5 @@ teardown() {
assert_line --index 2 --partial "fedora-toolbox:34"
assert_line --index 3 --partial "$default_image"
assert [ ${#lines[@]} -eq 5 ]
if check_bats_version 1.7.0; then
assert [ ${#stderr_lines[@]} -eq 0 ]
fi
assert [ ${#stderr_lines[@]} -eq 0 ]
}

0 comments on commit 3c50af3

Please sign in to comment.