summaryrefslogtreecommitdiff
path: root/test/cases/toru-path.bats
diff options
context:
space:
mode:
Diffstat (limited to 'test/cases/toru-path.bats')
-rw-r--r--test/cases/toru-path.bats56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/cases/toru-path.bats b/test/cases/toru-path.bats
new file mode 100644
index 0000000..5576ad7
--- /dev/null
+++ b/test/cases/toru-path.bats
@@ -0,0 +1,56 @@
+#!/usr/bin/env roundup
+
+describe toru-path
+. ./test-common.sh
+
+it_displays_help() {
+ LC_ALL=C toru-path -h >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]]
+ empty $tmpdir/stderr
+}
+
+it_runs() {
+ cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ TORUPATH=${tmpdir@Q}
+ REPOS=(libre)
+ eot
+ cat >> "$HOME/.abs.conf" <<-eot
+ ABSROOT=${PWD@Q}/toru.d
+ eot
+
+ toru-path
+
+ tcamgr list "$tmpdir/paths.tch"|LC_COLLATE=C sort|while read -r key; do
+ val="$(tcamgr get "$tmpdir/paths.tch" "$key")"
+ printf '«%q» -> «%q»\n' "$key" "$val"
+ done > "$tmpdir/paths-actual.txt"
+
+ printf '«%q» -> «%q»\n' \
+ BAR "$PWD/toru.d/libre/split-base" \
+ BAZ "$PWD/toru.d/libre/split-base" \
+ FOO "$PWD/toru.d/libre/split-base" \
+ bar "$PWD/toru.d/libre/split" \
+ baz "$PWD/toru.d/libre/split" \
+ foo "$PWD/toru.d/libre/split" \
+ simple "$PWD/toru.d/libre/simple" \
+ split-base "$PWD/toru.d/libre/split-base" \
+ > "$tmpdir/paths-expected.txt"
+
+ diff "$tmpdir/paths-expected.txt" "$tmpdir/paths-actual.txt"
+}
+
+it_sets_torupath() {
+ cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ TORUPATH=${tmpdir@Q}
+ REPOS=(libre)
+ eot
+ cat >> "$HOME/.abs.conf" <<-eot
+ ABSROOT=${PWD@Q}/toru.d
+ eot
+
+ mkdir -p "$tmpdir/x"
+ T="$tmpdir/x" toru-path
+ test -f "$tmpdir/x/paths.tch"
+ not test -e "$tmpdir/paths.tch"
+}