summaryrefslogtreecommitdiff
path: root/test/tests/link-if.bash
diff options
context:
space:
mode:
Diffstat (limited to 'test/tests/link-if.bash')
-rw-r--r--test/tests/link-if.bash51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/tests/link-if.bash b/test/tests/link-if.bash
new file mode 100644
index 0000000..1ea7709
--- /dev/null
+++ b/test/tests/link-if.bash
@@ -0,0 +1,51 @@
+test_description='link if'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+mkdir ~/d
+echo "apple" > ${DOTFILES}/f
+'
+
+test_expect_success 'run' '
+run_dotbot <<EOF
+- link:
+ ~/.f:
+ path: f
+ if: "true"
+ ~/.g:
+ path: f
+ if: "false"
+ ~/.h:
+ path: f
+ if: "[[ -d ~/d ]]"
+ ~/.i:
+ path: f
+ if: "badcommand"
+EOF
+'
+
+test_expect_success 'test' '
+grep "apple" ~/.f &&
+! test -f ~/.g &&
+grep "apple" ~/.h &&
+! test -f ~/.i
+'
+
+test_expect_success 'run 2' '
+run_dotbot <<EOF
+- defaults:
+ link:
+ if: "false"
+- link:
+ ~/.j:
+ path: f
+ if: "true"
+ ~/.k:
+ path: f
+EOF
+'
+
+test_expect_success 'test 2' '
+grep "apple" ~/.j &&
+! test -f ~/.k
+'