diff options
Diffstat (limited to 'test/cases/lib-blacklist.bats')
-rw-r--r-- | test/cases/lib-blacklist.bats | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/test/cases/lib-blacklist.bats b/test/cases/lib-blacklist.bats index 32d700d..2388b15 100644 --- a/test/cases/lib-blacklist.bats +++ b/test/cases/lib-blacklist.bats @@ -1,9 +1,6 @@ -#!/usr/bin/env roundup +load ../lib/common -describe libreblacklist -. ./test-common.sh - -it_works_with_just_pkgname() { +@test "libreblacklist works with just pkgname" { v="$(libreblacklist normalize <<<skype)"; [[ $v == 'skype::::' ]] v="$(libreblacklist get-pkg <<<skype)"; [[ $v == skype ]] libreblacklist get-rep <<<irreplaceable | equals $'\n' @@ -11,7 +8,7 @@ it_works_with_just_pkgname() { libreblacklist get-reason <<<skype | equals $'\n' } -it_works_with_everything_set() { +@test "libreblacklist works with everything set" { line='linux:conflict:parabola:id:[semifree] blobs and firmware' v="$(libreblacklist normalize <<<"$line")"; [[ $v == "$line" ]] v="$(libreblacklist get-pkg <<<"$line")"; [[ $v == 'linux' ]] @@ -20,7 +17,7 @@ it_works_with_everything_set() { v="$(libreblacklist get-reason <<<"$line")"; [[ $v == '[semifree] blobs and firmware' ]] } -it_normalizes_correctly() { +@test "libreblacklist normalizes correctly" { libreblacklist normalize <<<'#comment' | equals '' v="$(libreblacklist normalize <<<pkg)"; [[ $v == 'pkg::::' ]] v="$(libreblacklist normalize <<<pkg:)"; [[ $v == 'pkg::::' ]] @@ -34,7 +31,7 @@ it_normalizes_correctly() { v="$(libreblacklist normalize <<<pkg:rep:ref:id:reason)"; [[ $v == 'pkg:rep:ref:id:reason' ]] } -it_works_with_colons_in_reason() { +@test "libreblacklist works with colons in reason" { line='package:conflict:parabola:id:my:reason' v="$(libreblacklist normalize <<<"$line")"; [[ $v == "$line" ]] v="$(libreblacklist get-pkg <<<"$line")"; [[ $v == 'package' ]] @@ -43,12 +40,12 @@ it_works_with_colons_in_reason() { v="$(libreblacklist get-reason <<<"$line")"; [[ $v == 'my:reason' ]] } -it_prints_urls_only_for_valid_references() { +@test "libreblacklist prints urls only for valid references" { libreblacklist get-url <<<package:::id: | equals $'\n' libreblacklist get-url <<<package::unknown:id: | equals $'\n' } -it_fails_update_with_no_blacklist_or_network() { +@test "libreblacklist fails update with no blacklist or network" { cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot BLACKLIST='phony://example.com' eot @@ -60,7 +57,7 @@ it_fails_update_with_no_blacklist_or_network() { not empty $tmpdir/stderr } -it_fails_cat_with_no_blacklist_or_network() { +@test "libreblacklist fails cat with no blacklist or network" { cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot BLACKLIST='phony://example.com' eot @@ -72,7 +69,7 @@ it_fails_cat_with_no_blacklist_or_network() { not empty $tmpdir/stderr } -it_fails_update_when_BLACKLIST_is_unset() { +@test "libreblacklist fails update when BLACKLIST is unset" { cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot BLACKLIST= eot @@ -84,7 +81,7 @@ it_fails_update_when_BLACKLIST_is_unset() { not empty $tmpdir/stderr } -it_fails_cat_when_syntax_error_in_conf() { +@test "libreblacklist fails cat when syntax error in conf" { # there is a stray single quote in there cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot BLACKLIST='https://git.parabola.nu/blacklist.git/plain/blacklist.txt @@ -97,22 +94,22 @@ it_fails_cat_when_syntax_error_in_conf() { not empty $tmpdir/stderr } -it_downloads_the_blacklist_as_needed() { - require network || return 0 +@test "libreblacklist downloads the blacklist as needed" { + require network || skip libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr not empty $tmpdir/stdout } -it_downloads_the_blacklist_repeatedly() { - require network || return 0 +@test "libreblacklist downloads the blacklist repeatedly" { + require network || skip libreblacklist update libreblacklist update } -it_displays_help_and_fails_with_no_args() { +@test "libreblacklist displays help and fails with no args" { LC_ALL=C libreblacklist >$tmpdir/stdout 2>$tmpdir/stderr || status=$? [[ $status != 0 ]] @@ -120,14 +117,14 @@ it_displays_help_and_fails_with_no_args() { [[ "$(sed 1q $tmpdir/stderr)" =~ 'Usage: libreblacklist ' ]] } -it_displays_help_when_given_h() { +@test "libreblacklist displays help when given h" { LC_ALL=C libreblacklist -h >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q $tmpdir/stdout)" =~ 'Usage: libreblacklist ' ]] empty $tmpdir/stderr } -it_displays_help_when_given_h_cat() { +@test "libreblacklist displays help when given h cat" { LC_ALL=C libreblacklist -h cat >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q $tmpdir/stdout)" == 'Usage: libreblacklist cat' ]] |