diff options
author | Michael Allen <michael@michaelallen.io> | 2015-02-12 00:03:43 +0000 |
---|---|---|
committer | Michael Allen <michael@michaelallen.io> | 2015-02-12 00:03:43 +0000 |
commit | 0eeb5677650dc35ce3e3bef77b6a9a3154d221d2 (patch) | |
tree | d44bc3d4fa4351af23e7854ae9f32c2175f6eeda /unit-tests.sh | |
parent | 89fa3a5f520297bd353cd9720cc6d0d0e96a075a (diff) | |
download | git-sonar-0eeb5677650dc35ce3e3bef77b6a9a3154d221d2.tar.gz git-sonar-0eeb5677650dc35ce3e3bef77b6a9a3154d221d2.zip |
make and remove tmp dirs for tests to be more cleanly
Diffstat (limited to 'unit-tests.sh')
-rwxr-xr-x | unit-tests.sh | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/unit-tests.sh b/unit-tests.sh index 2f106e5..adf8ea8 100755 --- a/unit-tests.sh +++ b/unit-tests.sh @@ -1,18 +1,38 @@ - scriptDir="$(cd "$(dirname "$0")"; pwd)" source "$scriptDir/git-base.sh" +tmpfile="" + +cd_to_tmp() { + tmpfile="/tmp/git-prompt-tests-$(time_now)" + mkdir -p "$tmpfile" + cd "$tmpfile" +} + +rm_tmp() { + cd $scriptDir + rm -r "$tmpfile" +} + test_git_root_in_repo() { cd $scriptDir local root="$(git_root)" assertEquals "$scriptDir" "$root" } +test_git_root_not_in_repo() { + cd_to_tmp + local root="$(git_root)" + assertEquals "" "$root" + rm_tmp +} + test_dot_git_location_not_in_repo() { - cd / + cd_to_tmp local filePath="$(dot_git)" assertEquals "" "$filePath" + rm_tmp } test_dot_git_location_in_repo() { @@ -23,8 +43,9 @@ test_dot_git_location_in_repo() { } test_is_repo_not_in_repo() { - cd / + cd_to_tmp assertFalse is_repo + rm_tmp } test_is_repo_in_repo() { |