summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/libreblacklist-test.sh31
-rw-r--r--test/libremessages-test.sh11
-rw-r--r--test/pkgbuild-check-nonfree-test.sh2
3 files changed, 38 insertions, 6 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
diff --git a/test/libremessages-test.sh b/test/libremessages-test.sh
index 6da53d1..22aad47 100644
--- a/test/libremessages-test.sh
+++ b/test/libremessages-test.sh
@@ -21,11 +21,12 @@ it_can_be_included_with_set_euE() (
)
it_works_with_no_color_and_set_euE() (
- unset TERM
- set -euE
- . libremessages
-
- msg Foo >$tmpdir/stdout 2>$tmpdir/stderr
+ (
+ unset TERM
+ set -euE
+ . libremessages
+ msg Foo
+ ) >$tmpdir/stdout 2>$tmpdir/stderr
[[ -z "$(cat $tmpdir/stdout)" ]]
[[ -n "$(cat $tmpdir/stderr)" ]]
diff --git a/test/pkgbuild-check-nonfree-test.sh b/test/pkgbuild-check-nonfree-test.sh
index 703733a..8a2e349 100644
--- a/test/pkgbuild-check-nonfree-test.sh
+++ b/test/pkgbuild-check-nonfree-test.sh
@@ -55,7 +55,7 @@ it_fails_with_15_for_nonfree_depend() {
it_fails_when_there_is_no_blacklist() {
mkdir -p $XDG_CONFIG_HOME/libretools
- echo "BLACKLIST='http://phony'" >$XDG_CONFIG_HOME/libretools.conf
+ echo "BLACKLIST='http://phony'" >$XDG_CONFIG_HOME/libretools/libretools.conf
rm $XDG_CACHE_HOME/libretools/blacklist.txt
$pcn $pcn.PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?