summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2015-05-12 20:04:42 -0400
committerAnish Athalye <me@anishathalye.com>2015-05-12 20:28:58 -0400
commitfd7f3b85514b3aca17afda51ff0ee22937388451 (patch)
tree74d592b635dfb92e39646bfd1c3b109574861dc4 /test
parent53c26ba9e6ce2778c823efceb52340c40858e980 (diff)
Add environment variable expansion in link paths
This feature was proposed by Brian Knobbs <brian@redlattice.com>.
Diffstat (limited to 'test')
-rw-r--r--test/tests/link-environment-variable-expansion-source.bash18
-rw-r--r--test/tests/link-environment-variable-expansion-target.bash25
-rw-r--r--test/tests/link-environment-variable-unset.bash18
3 files changed, 61 insertions, 0 deletions
diff --git a/test/tests/link-environment-variable-expansion-source.bash b/test/tests/link-environment-variable-expansion-source.bash
new file mode 100644
index 0000000..50456d6
--- /dev/null
+++ b/test/tests/link-environment-variable-expansion-source.bash
@@ -0,0 +1,18 @@
+test_description='link expands environment variables in source'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+echo "grape" > ${DOTFILES}/h
+'
+
+test_expect_success 'run' '
+export APPLE="h" &&
+run_dotbot <<EOF
+- link:
+ ~/.i: \$APPLE
+EOF
+'
+
+test_expect_success 'test' '
+grep "grape" ~/.i
+'
diff --git a/test/tests/link-environment-variable-expansion-target.bash b/test/tests/link-environment-variable-expansion-target.bash
new file mode 100644
index 0000000..3a2e4dd
--- /dev/null
+++ b/test/tests/link-environment-variable-expansion-target.bash
@@ -0,0 +1,25 @@
+test_description='link expands environment variables in target'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+echo "apple" > ${DOTFILES}/f &&
+echo "grape" > ${DOTFILES}/h
+'
+
+test_expect_success 'run' '
+export ORANGE=".config" &&
+export BANANA="g" &&
+unset PEAR &&
+run_dotbot <<EOF
+- link:
+ ~/\${ORANGE}/\$BANANA:
+ path: f
+ create: true
+ ~/\$PEAR: h
+EOF
+'
+
+test_expect_success 'test' '
+grep "apple" ~/.config/g &&
+grep "grape" ~/\$PEAR
+'
diff --git a/test/tests/link-environment-variable-unset.bash b/test/tests/link-environment-variable-unset.bash
new file mode 100644
index 0000000..8673729
--- /dev/null
+++ b/test/tests/link-environment-variable-unset.bash
@@ -0,0 +1,18 @@
+test_description='link leaves unset environment variables'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+echo "apple" > ${DOTFILES}/\$ORANGE
+'
+
+test_expect_success 'run' '
+unset ORANGE &&
+run_dotbot <<EOF
+- link:
+ ~/.f: \$ORANGE
+EOF
+'
+
+test_expect_success 'test' '
+grep "apple" ~/.f
+'