summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-05-27 02:08:58 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-05-27 02:08:58 -0400
commit2ad4125443fbccf5e3c955f14dd2dd9c463b2557 (patch)
treedb2d8d04855f994dba81e14ebb035302e50d6b52 /test
parent4e36277689f92772e474c0829cb7f517aa06d58d (diff)
add tests for libreblacklist, fix a few bugs
Diffstat (limited to 'test')
-rw-r--r--test/libreblacklist-test.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/libreblacklist-test.sh b/test/libreblacklist-test.sh
new file mode 100644
index 0000000..f2fd457
--- /dev/null
+++ b/test/libreblacklist-test.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env roundup
+
+describe libreblacklist
+
+it_works_with_just_pkgname() {
+ 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 ]]
+}
+
+it_works_with_everything_set() {
+ line='linux:linux-libre:nonfree blobs and firmwares'
+ 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' ]]
+}
+
+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:' ]]
+}
+
+it_works_with_colons_in_reason() {
+ line='package:replacement:my:reason'
+ v="$(libreblacklist normalize <<<"$line")"; [[ $v == "$line" ]]
+ v="$(libreblacklist get-pkg <<<"$line")"; [[ $v == 'package' ]]
+ v="$(libreblacklist get-rep <<<"$line")"; [[ $v == 'replacement' ]]
+ v="$(libreblacklist get-reason <<<"$line")"; [[ $v == 'my:reason' ]]
+}
+
+# TODO: test blacklist-update, but I don't want tests to use network