summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/is_built-test.sh9
-rw-r--r--test/lib-blacklist-test.sh49
2 files changed, 50 insertions, 8 deletions
diff --git a/test/is_built-test.sh b/test/is_built-test.sh
index bcd46f5..04b17cd 100644
--- a/test/is_built-test.sh
+++ b/test/is_built-test.sh
@@ -21,17 +21,16 @@ it_displays_help() {
it_fails_with_0_args() {
is_built >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
- [[ $stat > 1 ]]
+ [[ $stat -gt 1 ]]
[[ -z "$(cat $tmpdir/stdout)" ]]
[[ -n "$(cat $tmpdir/stderr)" ]]
}
-it_fails_with_1_arg() {
- is_built sh >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+it_succeeds_with_1_arg() {
+ is_built sh >$tmpdir/stdout 2>$tmpdir/stderr
- [[ $stat > 1 ]]
[[ -z "$(cat $tmpdir/stdout)" ]]
- [[ -n "$(cat $tmpdir/stderr)" ]]
+ [[ -z "$(cat $tmpdir/stderr)" ]]
}
it_returns_1_for_non_existent_package() {
diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh
index 1432ff6..049a2a7 100644
--- a/test/lib-blacklist-test.sh
+++ b/test/lib-blacklist-test.sh
@@ -2,13 +2,14 @@
describe libreblacklist
+. ./test-common.sh
+
before() {
- tmpdir=$(mktemp -d --tmpdir test-libreblacklist.XXXXXXXXXXXX)
- stat=0
+ _before
}
after() {
- rm -rf -- "$tmpdir" "$XDG_CACHE_HOME" "$XDG_CONFIG_HOME"
+ _after
}
it_works_with_just_pkgname() {
@@ -66,6 +67,48 @@ it_fails_cat_when_there_is_no_blacklist_or_network() {
[[ -n "$(cat $tmpdir/stderr)" ]]
}
+it_fails_update_when_BLACKLIST_is_unset() {
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ echo "BLACKLIST=" >$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_syntax_error_in_conf() {
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ # there is a stray single quote in there
+ echo "BLACKLIST='https://repo.parabolagnulinux.org/docs/blacklist.txt" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
+
+it_downloads_the_blacklist_as_needed() {
+ require network || return 0
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ echo "BLACKLIST=https://repo.parabolagnulinux.org/docs/blacklist.txt" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ -n "$(cat $tmpdir/stdout)" ]]
+}
+
+it_downloads_the_blacklist_repeatedly() {
+ require network || return 0
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ echo "BLACKLIST=https://repo.parabolagnulinux.org/docs/blacklist.txt" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ libreblacklist update
+ libreblacklist update
+}
+
it_displays_help_and_fails_with_no_args() {
libreblacklist >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?