Skip to content

Commit

Permalink
Add tests for canonicalize-path
Browse files Browse the repository at this point in the history
  • Loading branch information
anishathalye committed Jan 3, 2020
1 parent 138fdbc commit 320d5d0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dotbot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def main():
if not isinstance(tasks, list):
raise ReadingError('Configuration file must be a list of tasks')
if options.base_directory:
base_directory = options.base_directory
base_directory = os.path.abspath(options.base_directory)
else:
# default to directory of config file
base_directory = os.path.dirname(os.path.realpath(options.config_file))
base_directory = os.path.dirname(os.path.abspath(options.config_file))
os.chdir(base_directory)
dispatcher = Dispatcher(base_directory)
success = dispatcher.dispatch(tasks)
Expand Down
20 changes: 20 additions & 0 deletions test/tests/link-canonicalize.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test_description='linking canonicalizes path by default'
. '../test-lib.bash'

test_expect_success 'setup' '
echo "apple" > ${DOTFILES}/f &&
ln -s dotfiles dotfiles-symlink
'

test_expect_success 'run' '
cat > "${DOTFILES}/${INSTALL_CONF}" <<EOF
- link:
~/.f:
path: f
EOF
${DOTBOT_EXEC} -c dotfiles-symlink/${INSTALL_CONF}
'

test_expect_success 'test' '
[ "$(readlink ~/.f | cut -d/ -f4-)" = "dotfiles/f" ]
'
23 changes: 23 additions & 0 deletions test/tests/link-no-canonicalize.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
test_description='linking path canonicalization can be disabled'
. '../test-lib.bash'

test_expect_success 'setup' '
echo "apple" > ${DOTFILES}/f &&
ln -s dotfiles dotfiles-symlink
'

test_expect_success 'run' '
cat > "${DOTFILES}/${INSTALL_CONF}" <<EOF
- defaults:
link:
canonicalize-path: false
- link:
~/.f:
path: f
EOF
${DOTBOT_EXEC} -c ./dotfiles-symlink/${INSTALL_CONF}
'

test_expect_success 'test' '
[ "$(readlink ~/.f | cut -d/ -f4-)" = "dotfiles-symlink/f" ]
'

0 comments on commit 320d5d0

Please sign in to comment.