summaryrefslogtreecommitdiff
path: root/test/cases/lib-conf.bats
diff options
context:
space:
mode:
Diffstat (limited to 'test/cases/lib-conf.bats')
-rw-r--r--test/cases/lib-conf.bats46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/cases/lib-conf.bats b/test/cases/lib-conf.bats
new file mode 100644
index 0000000..cf0b805
--- /dev/null
+++ b/test/cases/lib-conf.bats
@@ -0,0 +1,46 @@
+#!/usr/bin/env roundup
+
+describe lib/conf.sh
+. ./test-common.sh
+
+it_sets_makepkg_vars_in_custom_file() {
+ unset PKGDEST
+ touch "$tmpdir/makepkg.conf"
+ bash -c "$(printf '. $(librelib conf.sh); MAKEPKG_CONF=%q set_var makepkg PKGDEST /pkgdest' "$tmpdir/makepkg.conf")"
+ . "$tmpdir/makepkg.conf"
+ [[ $PKGDEST == /pkgdest ]]
+}
+
+it_figures_out_HOME_when_root() {
+ require sudo || return 0
+ # This one is tricky, because it does the job too well, it will find
+ # the actual HOME, instead of the test environment HOME. Therefore, we
+ # will just check that [[ $HOME != /root ]]
+ cd "$tmpdir"
+ echo '. $(librelib conf.sh); echo "$LIBREHOME"' > test.sh
+ LIBREHOME=$(testsudo bash ./test.sh)
+ [[ $LIBREHOME != /root ]]
+}
+
+it_nests_LIBREUSER() {
+ require sudo || return 0
+ [[ $USER != root ]]
+ cd "$tmpdir"
+ echo '. $(librelib conf.sh); echo "$LIBREUSER"' > test.sh
+
+ LIBREUSER=$(testsudo bash ./test.sh)
+ [[ $LIBREUSER == "$USER" ]]
+
+ LIBREUSER=$(testsudo testsudo -u "$USER" bash ./test.sh)
+ [[ $LIBREUSER == "$USER" ]]
+}
+
+it_respects_custom_HOME() {
+ cd "$tmpdir"
+ echo '. $(librelib conf.sh); echo "$LIBREHOME"' > test.sh
+
+ export HOME=/foo
+ LIBREHOME=$(bash ./test.sh)
+
+ [[ $LIBREHOME == /foo ]]
+}