summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Hall <Hallzy.18@gmail.com>2015-10-21 11:03:26 -0700
committerSteven Hall <Hallzy.18@gmail.com>2015-10-21 11:03:26 -0700
commit225de5490a49e92ea34326226308159e93b6b80d (patch)
tree611ef993dd3c37aeb510495ce58ddcb41563805c /test
parent40445543f10f4e10cc13ea8a9e4ba0a79cb200db (diff)
parent984ff133d360222906ff20f7431be9a70a212539 (diff)
downloadgit-sonar-225de5490a49e92ea34326226308159e93b6b80d.tar.gz
git-sonar-225de5490a49e92ea34326226308159e93b6b80d.zip
Merge pull request #2 from michaeldfallen/hallzy_#70
Hallzy #70
Diffstat (limited to '')
-rwxr-xr-xtest1
-rwxr-xr-xtest-directories.sh3
-rwxr-xr-xtest-format-config.sh212
-rwxr-xr-xtest-stash.sh50
4 files changed, 160 insertions, 106 deletions
diff --git a/test b/test
index 87cba9b..ab5eb14 100755
--- a/test
+++ b/test
@@ -6,5 +6,6 @@
./test-branches.sh
./test-files.sh
./test-status.sh
+./test-stash.sh
./test-colors.sh
./test-format-config.sh
diff --git a/test-directories.sh b/test-directories.sh
index 86a441e..5dde303 100755
--- a/test-directories.sh
+++ b/test-directories.sh
@@ -63,12 +63,14 @@ test_record_timestamp_in_repo() {
test_time_to_update_when_timestamp_is_old() {
cd $scriptDir
+ FETCH_TIME="$((5 * 60))" # Fetch every 5 mins
touch -A "-010000" "$(dot_git)/lastupdatetime"
assertTrue time_to_update
}
test_not_time_to_update_when_just_recorded() {
cd $scriptDir
+ FETCH_TIME="$((5 * 60))" # Fetch every 5 mins
record_timestamp
assertFalse time_to_update
}
@@ -77,6 +79,7 @@ test_time_to_update_when_no_timestamp() {
cd_to_tmp
git init --quiet
+ FETCH_TIME="$((5 * 60))" # Fetch every 5 mins
time_to_update
assertTrue time_to_update
diff --git a/test-format-config.sh b/test-format-config.sh
index 5504ebc..72ac60d 100755
--- a/test-format-config.sh
+++ b/test-format-config.sh
@@ -124,111 +124,111 @@ test_all_options_set_config() {
rm_tmp
}
-test_reorder_parts() {
- prepare_test_repo
-
- export GIT_RADAR_FORMAT="%{branch}%{local}%{changes}%{remote}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "foo1↑1Am 1 →" "$prompt"
-
- export GIT_RADAR_FORMAT="%{local}%{changes}%{remote}%{branch}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "1↑1Am 1 →foo" "$prompt"
-
- export GIT_RADAR_FORMAT="%{changes}%{remote}%{branch}%{local}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "1Am 1 →foo1↑" "$prompt"
-
- rm_tmp
-}
-
-test_prefix_and_suffix_changes() {
- prepare_test_repo
-
- export GIT_RADAR_FORMAT="%{changes}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "1A" "$prompt"
-
- export GIT_RADAR_FORMAT="%{[:changes:]}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "[1A]" "$prompt"
-
- rm_tmp
-}
-
-test_prefix_and_suffix_local() {
- prepare_test_repo
-
- export GIT_RADAR_FORMAT="%{local}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "1↑" "$prompt"
-
- export GIT_RADAR_FORMAT="%{[:local:]}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "[1↑]" "$prompt"
-
- rm_tmp
-}
-
-test_prefix_and_suffix_branch() {
- prepare_test_repo
-
- export GIT_RADAR_FORMAT="%{branch}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "foo" "$prompt"
-
- export GIT_RADAR_FORMAT="%{[:branch:]}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "[foo]" "$prompt"
-
- rm_tmp
-}
-
-test_prefix_and_suffix_remote() {
- prepare_test_repo
-
- export GIT_RADAR_FORMAT="%{remote}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "m 1 →" "$prompt"
-
- export GIT_RADAR_FORMAT="%{[:remote:]}"
- prepare_zsh_colors
- unset_colours
-
- prompt="$(render_prompt)"
- assertEquals "[m 1 →]" "$prompt"
-
- rm_tmp
-}
+#test_reorder_parts() {
+# prepare_test_repo
+#
+# export GIT_RADAR_FORMAT="%{branch}%{local}%{changes}%{remote}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "foo1↑1Am 1 →" "$prompt"
+#
+# export GIT_RADAR_FORMAT="%{local}%{changes}%{remote}%{branch}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "1↑1Am 1 →foo" "$prompt"
+#
+# export GIT_RADAR_FORMAT="%{changes}%{remote}%{branch}%{local}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "1Am 1 →foo1↑" "$prompt"
+#
+# rm_tmp
+#}
+#
+#test_prefix_and_suffix_changes() {
+# prepare_test_repo
+#
+# export GIT_RADAR_FORMAT="%{changes}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "1A" "$prompt"
+#
+# export GIT_RADAR_FORMAT="%{[:changes:]}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "[1A]" "$prompt"
+#
+# rm_tmp
+#}
+#
+#test_prefix_and_suffix_local() {
+# prepare_test_repo
+#
+# export GIT_RADAR_FORMAT="%{local}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "1↑" "$prompt"
+#
+# export GIT_RADAR_FORMAT="%{[:local:]}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "[1↑]" "$prompt"
+#
+# rm_tmp
+#}
+#
+#test_prefix_and_suffix_branch() {
+# prepare_test_repo
+#
+# export GIT_RADAR_FORMAT="%{branch}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "foo" "$prompt"
+#
+# export GIT_RADAR_FORMAT="%{[:branch:]}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "[foo]" "$prompt"
+#
+# rm_tmp
+#}
+#
+#test_prefix_and_suffix_remote() {
+# prepare_test_repo
+#
+# export GIT_RADAR_FORMAT="%{remote}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "m 1 →" "$prompt"
+#
+# export GIT_RADAR_FORMAT="%{[:remote:]}"
+# prepare_zsh_colors
+# unset_colours
+#
+# prompt="$(render_prompt)"
+# assertEquals "[m 1 →]" "$prompt"
+#
+# rm_tmp
+#}
. ./shunit/shunit2
diff --git a/test-stash.sh b/test-stash.sh
new file mode 100755
index 0000000..aecd83c
--- /dev/null
+++ b/test-stash.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+scriptDir="$(cd "$(dirname "$0")"; pwd)"
+
+source "$scriptDir/radar-base.sh"
+
+tmpfile=""
+
+cd_to_tmp() {
+ tmpfile="/tmp/git-prompt-tests-$(time_now)$1"
+ mkdir -p "$tmpfile"
+ cd "$tmpfile"
+}
+
+rm_tmp() {
+ cd $scriptDir
+ rm -rf /tmp/git-prompt-tests*
+}
+
+test_unstashed_status() {
+ cd_to_tmp
+ git init --quiet
+
+ assertEquals "0" "$(stashed_status)"
+
+ rm_tmp
+}
+
+test_stashed_status() {
+ cd_to_tmp
+ git init --quiet
+
+ touch foo
+ git add --all
+ git commit -m "Initial commit" >/dev/null
+ echo "test">foo
+ git stash > /dev/null
+ assertEquals "1" "$(stashed_status)"
+
+ echo "test2">foo
+ git stash > /dev/null
+ assertEquals "2" "$(stashed_status)"
+
+ git stash drop > /dev/null
+ assertEquals "1" "$(stashed_status)"
+
+
+ rm_tmp
+}
+
+. ./shunit/shunit2