Massive restructuring code-base

This commit is contained in:
2014-03-19 21:03:31 +00:00
parent 4974654e75
commit 5567a98bb3
47 changed files with 610 additions and 395 deletions

View File

@@ -3,48 +3,53 @@ source "../../test-helper.sh"
source "../../../src/lib/internals/create-symlink.sh"
#
# create-symlink() tests
# dotify-create-symlink() tests
#
# Create temp files/folders used for create-symlink() tests.
# Create temp files/folders used for dotify-create-symlink() tests.
mkdir -p "tmp/source" "tmp/target"
touch "tmp/source/profile"
# Creates a normal symlink.
assert_raises 'create-symlink ../source tmp/target/.dotfiles' 0
assert_raises 'dotify-create-symlink ../source tmp/target/.dotfiles' 0
assert 'readlink tmp/target/.dotfiles' "../source"
rm "tmp/target/.dotfiles"
assert 'dotify-create-symlink ../source tmp/target/.dotfiles' "created"
rm "tmp/target/.dotfiles"
assert 'dotify-create-symlink ../source tmp/target/.dotfiles 2>&1' "created"
rm "tmp/target/.dotfiles"
# When target exists an is a symlink to the same source.
# When target exists and is a symlink to the same source.
ln -s "../source" "tmp/target/.dotfiles"
assert_raises 'create-symlink ../source tmp/target/.dotfiles' 0
assert 'create-symlink ../source tmp/target/.dotfiles 2>&1' ""
assert_raises 'dotify-create-symlink ../source tmp/target/.dotfiles' 0
assert 'dotify-create-symlink ../source tmp/target/.dotfiles' "exists"
assert 'dotify-create-symlink ../source tmp/target/.dotfiles 2>&1' "exists"
rm "tmp/target/.dotfiles"
# When target exists and is a symlink to a different source.
ln -s "../other" "tmp/target/.dotfiles"
assert_raises 'create-symlink ../source tmp/target/.dotfiles' 1
assert 'create-symlink ../source tmp/target/.dotfiles' ""
assert 'create-symlink ../source tmp/target/.dotfiles 2>&1' \
assert_raises 'dotify-create-symlink ../source tmp/target/.dotfiles' 1
assert 'dotify-create-symlink ../source tmp/target/.dotfiles' ""
assert 'dotify-create-symlink ../source tmp/target/.dotfiles 2>&1' \
"ERROR: \"tmp/target/.dotfiles\" exists, is a symlink to: ../other"
rm "tmp/target/.dotfiles"
# When target exists and is a file.
touch "tmp/target/.profile"
assert_raises 'create-symlink ../source/profile tmp/target/.profile' 1
assert 'create-symlink ../source/profile tmp/target/.profile' ""
assert 'create-symlink ../source/profile tmp/target/.profile 2>&1' \
assert_raises 'dotify-create-symlink ../source/profile tmp/target/.profile' 1
assert 'dotify-create-symlink ../source/profile tmp/target/.profile' ""
assert 'dotify-create-symlink ../source/profile tmp/target/.profile 2>&1' \
"ERROR: \"tmp/target/.profile\" exists"
rm "tmp/target/.profile"
# When target exists and is a directory.
assert_raises 'create-symlink ../source tmp/target' 1
assert 'create-symlink ../source tmp/target' ""
assert 'create-symlink ../source tmp/target 2>&1' \
assert_raises 'dotify-create-symlink ../source tmp/target' 1
assert 'dotify-create-symlink ../source tmp/target' ""
assert 'dotify-create-symlink ../source tmp/target 2>&1' \
"ERROR: \"tmp/target\" exists"
# Remove temp files/folders used for locate-dotfile() tests.
rm "tmp/source/profile"
rmdir "tmp/source" "tmp/target" "tmp"
assert_end 'create-symlink()'
assert_end 'dotify-create-symlink()'