summaryrefslogtreecommitdiff
path: root/test/libreblacklist-test.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-05-27 20:31:01 -0600
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-05-27 20:31:01 -0600
commit47fb685c2d6df5995134e9b8d322f667058e505e (patch)
tree7ab4e25a2233db0bb4bd9fd5f7d1228db271d1d0 /test/libreblacklist-test.sh
parentd13ea2efafcaea45961b43a736261fe35bf2a6e7 (diff)
fix and add unit tests
Diffstat (limited to 'test/libreblacklist-test.sh')
-rw-r--r--test/libreblacklist-test.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/libreblacklist-test.sh b/test/libreblacklist-test.sh
index f2fd457..94f5b27 100644
--- a/test/libreblacklist-test.sh
+++ b/test/libreblacklist-test.sh
@@ -2,6 +2,15 @@
describe libreblacklist
+before() {
+ tmpdir=$(mktemp -d --tmpdir test-libreblacklist.XXXXXXXXXXXX)
+ stat=0
+}
+
+after() {
+ rm -rf -- "$tmpdir" "$XDG_CACHE_HOME" "$XDG_CONFIG_HOME"
+}
+
it_works_with_just_pkgname() {
v="$(libreblacklist normalize <<<skype)"; [[ $v == 'skype::' ]]
v="$(libreblacklist get-pkg <<<skype)"; [[ $v == skype ]]
@@ -35,4 +44,26 @@ it_works_with_colons_in_reason() {
v="$(libreblacklist get-reason <<<"$line")"; [[ $v == 'my:reason' ]]
}
+it_fails_update_when_there_is_no_blacklist_or_network() {
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ echo "BLACKLIST='http://phony'" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
+
+it_fails_cat_when_there_is_no_blacklist_or_network() {
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ echo "BLACKLIST='http://phony'" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
+
# TODO: test blacklist-update, but I don't want tests to use network