diff options
author | Michael Allen <michael@michaelallen.io> | 2015-02-11 23:39:19 +0000 |
---|---|---|
committer | Michael Allen <michael@michaelallen.io> | 2015-02-11 23:39:19 +0000 |
commit | 89fa3a5f520297bd353cd9720cc6d0d0e96a075a (patch) | |
tree | f135adf522dbd99bba868ba9f4da9803c8242298 /unit-tests.sh | |
parent | db4d3a9c42b788561bfd15d32a841cd1e8fd5a5f (diff) | |
download | git-sonar-89fa3a5f520297bd353cd9720cc6d0d0e96a075a.tar.gz git-sonar-89fa3a5f520297bd353cd9720cc6d0d0e96a075a.zip |
turning some tests into proper shunit tests and found a few bugs
Diffstat (limited to 'unit-tests.sh')
-rwxr-xr-x | unit-tests.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/unit-tests.sh b/unit-tests.sh new file mode 100755 index 0000000..2f106e5 --- /dev/null +++ b/unit-tests.sh @@ -0,0 +1,55 @@ + +scriptDir="$(cd "$(dirname "$0")"; pwd)" + +source "$scriptDir/git-base.sh" + +test_git_root_in_repo() { + cd $scriptDir + local root="$(git_root)" + assertEquals "$scriptDir" "$root" +} + +test_dot_git_location_not_in_repo() { + cd / + local filePath="$(dot_git)" + assertEquals "" "$filePath" +} + +test_dot_git_location_in_repo() { + cd $scriptDir + local filePath="$(dot_git)" + local expected=".git" + assertEquals "$expected" "$filePath" +} + +test_is_repo_not_in_repo() { + cd / + assertFalse is_repo +} + +test_is_repo_in_repo() { + cd $scriptDir + assertTrue is_repo +} + +test_record_timestamp_in_repo() { + cd $scriptDir + record_timestamp + local timestamp="$(timestamp)" + local timenow="$(time_now)" + assertSame "$timenow" "$timestamp" +} + +test_time_to_update_when_timestamp_is_old() { + cd $scriptDir + touch -A "-010000" "$(dot_git)/lastupdatetime" + assertTrue time_to_update +} + +test_not_time_to_update_when_just_recorded() { + cd $scriptDir + record_timestamp + assertFalse time_to_update +} + +. ./shunit/shunit2 |