diff options
author | Michael Allen <michael@michaelallen.io> | 2015-08-10 22:05:07 +0100 |
---|---|---|
committer | Michael Allen <michael@michaelallen.io> | 2015-08-10 22:05:07 +0100 |
commit | 1f3b218b5cf79a414344b465cbb75af726721649 (patch) | |
tree | bfe92ab3baeab6ab1cf095bb5ce826394f823d6a | |
parent | 55fa93c2cdcecfb96c4de689976dca3dd4ce259b (diff) | |
download | git-sonar-1f3b218b5cf79a414344b465cbb75af726721649.tar.gz git-sonar-1f3b218b5cf79a414344b465cbb75af726721649.zip |
Move local commit test to commits test file
-rwxr-xr-x | test-commits.sh | 56 | ||||
-rwxr-xr-x | test-local-commit.sh | 73 |
2 files changed, 56 insertions, 73 deletions
diff --git a/test-commits.sh b/test-commits.sh index 01b07d3..083c38c 100755 --- a/test-commits.sh +++ b/test-commits.sh @@ -368,4 +368,60 @@ test_quiet_if_no_remote_master() { rm_tmp } + +test_zsh_and_bash_local_commits() { + local zsh_up="%{[green]%}↑%{%}" + local zsh_both="%{[yellow]%}⇵%{%}" + local zsh_down="%{[red]%}↓%{%}" + + printf -v bash_up '\033[1;32m↑\033[0m' + printf -v bash_both '\033[1;33m⇵\033[0m' + printf -v bash_down '\033[1;31m↓\033[0m' + + cd_to_tmp "remote" + + assertEquals "" "$(zsh_color_local_commits)" + assertEquals "" "$(bash_color_local_commits)" + + git init --quiet + touch README + git add . + git commit -m "initial commit" --quiet + remote="$(pwd)" + + cd_to_tmp "new" + git init --quiet + git remote add origin $remote + git fetch origin --quiet + git checkout master --quiet + repo="$(pwd)" + + assertEquals "" "$(zsh_color_local_commits)" + assertEquals "" "$(bash_color_local_commits)" + + cd "$repo" + echo "bar" > bar + git add . + git commit -m "test commit" --quiet + + assertEquals " 1$zsh_up" "$(zsh_color_local_commits)" + assertEquals " 1$bash_up" "$(bash_color_local_commits)" + + cd "$remote" + echo "foo" > foo + git add . + git commit -m "test commit" --quiet + + cd "$repo" + git fetch origin --quiet + + assertEquals " 1${zsh_both}1" "$(zsh_color_local_commits)" + assertEquals " 1${bash_both}1" "$(bash_color_local_commits)" + + git reset --hard HEAD^ --quiet + + assertEquals " 1$zsh_down" "$(zsh_color_local_commits)" + assertEquals " 1$bash_down" "$(bash_color_local_commits)" +} + . ./shunit/shunit2 diff --git a/test-local-commit.sh b/test-local-commit.sh deleted file mode 100755 index 68fe467..0000000 --- a/test-local-commit.sh +++ /dev/null @@ -1,73 +0,0 @@ -scriptDir="$(cd "$(dirname "$0")"; pwd)" - -source "$scriptDir/git-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_zsh_and_bash_local_commits() { - local zsh_up="%{[green]%}↑%{%}" - local zsh_both="%{[yellow]%}⇵%{%}" - local zsh_down="%{[red]%}↓%{%}" - - printf -v bash_up '\033[1;32m↑\033[0m' - printf -v bash_both '\033[1;33m⇵\033[0m' - printf -v bash_down '\033[1;31m↓\033[0m' - - cd_to_tmp "remote" - - assertEquals "" "$(zsh_color_local_commits)" - assertEquals "" "$(bash_color_local_commits)" - - git init --quiet - touch README - git add . - git commit -m "initial commit" --quiet - remote="$(pwd)" - - cd_to_tmp "new" - git init --quiet - git remote add origin $remote - git fetch origin --quiet - git checkout master --quiet - repo="$(pwd)" - - assertEquals "" "$(zsh_color_local_commits)" - assertEquals "" "$(bash_color_local_commits)" - - cd "$repo" - echo "bar" > bar - git add . - git commit -m "test commit" --quiet - - assertEquals " 1$zsh_up" "$(zsh_color_local_commits)" - assertEquals " 1$bash_up" "$(bash_color_local_commits)" - - cd "$remote" - echo "foo" > foo - git add . - git commit -m "test commit" --quiet - - cd "$repo" - git fetch origin --quiet - - assertEquals " 1${zsh_both}1" "$(zsh_color_local_commits)" - assertEquals " 1${bash_both}1" "$(bash_color_local_commits)" - - git reset --hard HEAD^ --quiet - - assertEquals " 1$zsh_down" "$(zsh_color_local_commits)" - assertEquals " 1$bash_down" "$(bash_color_local_commits)" -} - -. ./shunit/shunit2 |