diff options
Diffstat (limited to 'test/lib-blacklist-test.sh')
-rwxr-xr-x[-rw-r--r--] | test/lib-blacklist-test.sh | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh index 49c756e..7b88b72 100644..100755 --- a/test/lib-blacklist-test.sh +++ b/test/lib-blacklist-test.sh @@ -6,38 +6,50 @@ describe libreblacklist _blacklist_url=https://projects.parabola.nu/blacklist.git/plain/blacklist.txt it_works_with_just_pkgname() { - v="$(libreblacklist normalize <<<skype)"; [[ $v == 'skype::' ]] + v="$(libreblacklist normalize <<<skype)"; [[ $v == 'skype::::' ]] v="$(libreblacklist get-pkg <<<skype)"; [[ $v == skype ]] - v="$(libreblacklist get-rep <<<skype)"; [[ -z $v ]] - v="$(libreblacklist get-reason <<<skype)"; [[ -z $v ]] + libreblacklist get-rep <<<irreplaceable | equals $'\n' + libreblacklist get-url <<<skype | equals $'\n' + libreblacklist get-reason <<<skype | equals $'\n' } it_works_with_everything_set() { - line='linux:linux-libre:nonfree blobs and firmwares' + line='linux:conflict:parabola:id:[semifree] blobs and firmware' v="$(libreblacklist normalize <<<"$line")"; [[ $v == "$line" ]] v="$(libreblacklist get-pkg <<<"$line")"; [[ $v == 'linux' ]] - v="$(libreblacklist get-rep <<<"$line")"; [[ $v == 'linux-libre' ]] - v="$(libreblacklist get-reason <<<"$line")"; [[ $v == 'nonfree blobs and firmwares' ]] + v="$(libreblacklist get-rep <<<"$line")"; [[ $v == 'libre/linux-libre' ]] + v="$(libreblacklist get-url <<<"$line")"; [[ $v == 'https://labs.parabola.nu/issues/id' ]] + v="$(libreblacklist get-reason <<<"$line")"; [[ $v == '[semifree] blobs and firmware' ]] } it_normalizes_correctly() { - v="$(libreblacklist normalize <<<pkg)"; [[ $v == 'pkg::' ]] - v="$(libreblacklist normalize <<<pkg:)"; [[ $v == 'pkg::' ]] - v="$(libreblacklist normalize <<<pkg::)"; [[ $v == 'pkg::' ]] - v="$(libreblacklist normalize <<<pkg:rep)"; [[ $v == 'pkg:rep:' ]] - v="$(libreblacklist normalize <<<pkg:rep:)"; [[ $v == 'pkg:rep:' ]] - v="$(libreblacklist normalize <<<pkg:rep:reason)"; [[ $v == 'pkg:rep:reason' ]] - v="$(libreblacklist normalize <<<pkg:rep:reason:)"; [[ $v == 'pkg:rep:reason:' ]] + libreblacklist normalize <<<'#comment' | equals '' + v="$(libreblacklist normalize <<<pkg)"; [[ $v == 'pkg::::' ]] + v="$(libreblacklist normalize <<<pkg:)"; [[ $v == 'pkg::::' ]] + v="$(libreblacklist normalize <<<pkg::)"; [[ $v == 'pkg::::' ]] + v="$(libreblacklist normalize <<<pkg:rep)"; [[ $v == 'pkg:rep:::' ]] + v="$(libreblacklist normalize <<<pkg:rep:)"; [[ $v == 'pkg:rep:::' ]] + v="$(libreblacklist normalize <<<pkg:rep:ref)"; [[ $v == 'pkg:rep:ref::' ]] + v="$(libreblacklist normalize <<<pkg:rep:ref:)"; [[ $v == 'pkg:rep:ref::' ]] + v="$(libreblacklist normalize <<<pkg:rep:ref:id)"; [[ $v == 'pkg:rep:ref:id:' ]] + v="$(libreblacklist normalize <<<pkg:rep:ref:id:)"; [[ $v == 'pkg:rep:ref:id:' ]] + v="$(libreblacklist normalize <<<pkg:rep:ref:id:reason)"; [[ $v == 'pkg:rep:ref:id:reason' ]] } it_works_with_colons_in_reason() { - line='package:replacement:my:reason' + line='package:conflict:parabola:id:my:reason' v="$(libreblacklist normalize <<<"$line")"; [[ $v == "$line" ]] v="$(libreblacklist get-pkg <<<"$line")"; [[ $v == 'package' ]] - v="$(libreblacklist get-rep <<<"$line")"; [[ $v == 'replacement' ]] + libreblacklist get-rep <<<"$line" | equals $'\n' + v="$(libreblacklist get-url <<<"$line")"; [[ $v == 'https://labs.parabola.nu/issues/id' ]] v="$(libreblacklist get-reason <<<"$line")"; [[ $v == 'my:reason' ]] } +it_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() { mkdir -p $XDG_CONFIG_HOME/libretools echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf |