mirror of
https://github.com/jimeh/dotify.git
synced 2026-02-19 10:06:39 +00:00
Reorganize internal functions
This commit is contained in:
36
test/lib/internals/locate-target-test.sh
Executable file
36
test/lib/internals/locate-target-test.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#! /usr/bin/env bash
|
||||
source "../../test-helper.sh"
|
||||
source "../../../src/lib/internals.sh"
|
||||
|
||||
#
|
||||
# locate-target() tests
|
||||
#
|
||||
|
||||
# When $TARGET is empty.
|
||||
TARGET=""
|
||||
assert_raises 'locate-target' 0
|
||||
assert 'locate-target; echo "$TARGET"' "$HOME"
|
||||
unset TARGET
|
||||
|
||||
# When $TARGET is not empty and is a directory.
|
||||
TARGET="$(pwd)"
|
||||
assert_raises 'locate-target' 0
|
||||
assert 'locate-target; echo "$TARGET"' "$(pwd)"
|
||||
unset TARGET
|
||||
|
||||
# When $TARGET is not empty and is not a directory.
|
||||
TARGET="/tmp/this/does/not/exist"
|
||||
assert_raises 'locate-target' 1
|
||||
assert 'locate-target 2>&1' "ERROR: Target \"$TARGET\" is not a directory."
|
||||
assert 'locate-target; echo "$TARGET"' "$TARGET"
|
||||
unset TARGET
|
||||
|
||||
# If neither $TARGET or $HOME is set, ~ is expanded to find home folder
|
||||
original_home="$HOME"
|
||||
unset HOME
|
||||
assert_raises 'locate-target' 0
|
||||
assert 'locate-target; echo "$TARGET"' "$original_home"
|
||||
HOME="$original_home"
|
||||
|
||||
# End of locate-target() tests.
|
||||
assert_end 'locate-target()'
|
||||
Reference in New Issue
Block a user