summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2016-04-05 18:04:42 -0400
committerAnish Athalye <me@anishathalye.com>2016-04-07 14:45:46 -0400
commit191559601a8cd6ba2d9e7c3e429efa694f6ff460 (patch)
treede58d83b79b0cd78e04726212dc2ccf9949c8473 /test
parent3d9b3ae2a8bf97ba6ad7c9ae7d8fd4be9f66f597 (diff)
Fix linking when using both relink and relative
Prior to this patch, the following config led to incorrect behavior: - link: ~/.folder/file: path: file create: true relative: true relink: true Prior to the change, running the config the first time would result in expected behavior. However, running the config for the second time would result in deletion and re-creation of the link (even when the link is correct). This patch improves the interaction of relink and relative, taking relative paths into account when checking the validity of existing links in the `_delete()` method.
Diffstat (limited to 'test')
-rw-r--r--test/tests/link-relink-relative-leaves-file.bash32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/tests/link-relink-relative-leaves-file.bash b/test/tests/link-relink-relative-leaves-file.bash
new file mode 100644
index 0000000..af49174
--- /dev/null
+++ b/test/tests/link-relink-relative-leaves-file.bash
@@ -0,0 +1,32 @@
+test_description='relink relative does not incorrectly relink file'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+echo "apple" > ${DOTFILES}/f &&
+echo "grape" > ~/.f
+'
+
+test_expect_success 'run1' '
+run_dotbot <<EOF
+- link:
+ ~/.folder/f:
+ path: f
+ create: true
+ relative: true
+EOF
+'
+
+# these are done in a single block because they run in a subshell, and it
+# wouldn't be possible to access `$mtime` outside of the subshell
+test_expect_success 'test' '
+mtime=$(stat ~/.folder/f | grep Modify)
+run_dotbot <<EOF
+- link:
+ ~/.folder/f:
+ path: f
+ create: true
+ relative: true
+ relink: true
+EOF
+[[ "$mtime" == "$(stat ~/.folder/f | grep Modify)" ]]
+'