summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorClaudio Bandera <claudio.bandera@kit.edu>2015-09-17 18:40:24 +0200
committerClaudio Bandera <claudio.bandera@kit.edu>2015-09-17 18:40:24 +0200
commit92c2e869763dcc25c840c2e6cfcd9863abf201dd (patch)
treee032548195fccf98708daafa8f3e93c0781ede4e /test
parent2dbf0c220fc971c9493392a70c71954001fee7fd (diff)
parent1f6a8f84946a0cb6936916f47b5a3870fa12a5a6 (diff)
downloadgit-sonar-92c2e869763dcc25c840c2e6cfcd9863abf201dd.tar.gz
git-sonar-92c2e869763dcc25c840c2e6cfcd9863abf201dd.zip
Merge remote-tracking branch 'upstream/master' into hotfix/unittests
Diffstat (limited to '')
-rwxr-xr-xtest2
-rwxr-xr-xtest-branches.sh2
-rwxr-xr-xtest-colors.sh492
-rwxr-xr-xtest-commits.sh29
-rwxr-xr-xtest-radar-base.sh28
5 files changed, 539 insertions, 14 deletions
diff --git a/test b/test
index a6a8775..4efeafd 100755
--- a/test
+++ b/test
@@ -1,7 +1,9 @@
#!/bin/sh
+./test-radar-base.sh
./test-directories.sh
./test-commits.sh
./test-branches.sh
./test-files.sh
./test-status.sh
+./test-colors.sh
diff --git a/test-branches.sh b/test-branches.sh
index b972a25..b3f0ac2 100755
--- a/test-branches.sh
+++ b/test-branches.sh
@@ -55,6 +55,8 @@ test_detached_from_branch() {
assertNotEquals "master" "$(branch_name)"
assertEquals "$sha" "$(branch_ref)"
+ assertEquals "detached@$sha" "$(zsh_readable_branch_name)"
+ assertEquals "detached@$sha" "$(bash_readable_branch_name)"
assertEquals "detached@$sha" "$(readable_branch_name)"
rm_tmp
diff --git a/test-colors.sh b/test-colors.sh
new file mode 100755
index 0000000..73c20f7
--- /dev/null
+++ b/test-colors.sh
@@ -0,0 +1,492 @@
+scriptDir="$(cd "$(dirname "$0")"; pwd)"
+
+source "$scriptDir/radar-base.sh"
+
+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*
+}
+
+mock_zsh_colors() {
+ fg_bold[green]=1
+ fg_bold[red]=2
+ fg_bold[yellow]=3
+ fg_bold[white]=4
+
+ reset_color=0
+}
+
+test_no_rcfile_bash() {
+ reset_env_vars
+ prepare_bash_colors
+
+ assertEquals "$COLOR_REMOTE_AHEAD" "\x01\033[1;32m\x02"
+ assertEquals "$COLOR_REMOTE_BEHIND" "\x01\033[1;31m\x02"
+ assertEquals "$COLOR_REMOTE_DIVERGED" "\x01\033[1;33m\x02"
+ assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "\x01\033[1;31m\x02"
+
+ assertEquals "$COLOR_LOCAL_AHEAD" "\x01\033[1;32m\x02"
+ assertEquals "$COLOR_LOCAL_BEHIND" "\x01\033[1;31m\x02"
+ assertEquals "$COLOR_LOCAL_DIVERGED" "\x01\033[1;33m\x02"
+
+ assertEquals "$COLOR_CHANGES_STAGED" "\x01\033[1;32m\x02"
+ assertEquals "$COLOR_CHANGES_UNSTAGED" "\x01\033[1;31m\x02"
+ assertEquals "$COLOR_CHANGES_CONFLICTED" "\x01\033[1;33m\x02"
+ assertEquals "$COLOR_CHANGES_UNTRACKED" "\x01\033[1;37m\x02"
+
+ assertEquals "$RESET_COLOR_LOCAL" "\x01\033[0m\x02"
+ assertEquals "$RESET_COLOR_REMOTE" "\x01\033[0m\x02"
+ assertEquals "$RESET_COLOR_CHANGES" "\x01\033[0m\x02"
+}
+
+test_no_rcfile_zsh() {
+ reset_env_vars
+ mock_zsh_colors
+ prepare_zsh_colors
+
+ assertEquals "$COLOR_REMOTE_AHEAD" "%{$fg_bold[green]%}"
+ assertEquals "$COLOR_REMOTE_BEHIND" "%{$fg_bold[red]%}"
+ assertEquals "$COLOR_REMOTE_DIVERGED" "%{$fg_bold[yellow]%}"
+ assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "%{$fg_bold[red]%}"
+
+ assertEquals "$COLOR_LOCAL_AHEAD" "%{$fg_bold[green]%}"
+ assertEquals "$COLOR_LOCAL_BEHIND" "%{$fg_bold[red]%}"
+ assertEquals "$COLOR_LOCAL_DIVERGED" "%{$fg_bold[yellow]%}"
+
+ assertEquals "$COLOR_CHANGES_STAGED" "%{$fg_bold[green]%}"
+ assertEquals "$COLOR_CHANGES_UNSTAGED" "%{$fg_bold[red]%}"
+ assertEquals "$COLOR_CHANGES_CONFLICTED" "%{$fg_bold[yellow]%}"
+ assertEquals "$COLOR_CHANGES_UNTRACKED" "%{$fg_bold[white]%}"
+
+ assertEquals "$RESET_COLOR_LOCAL" "%{$reset_color%}"
+ assertEquals "$RESET_COLOR_REMOTE" "%{$reset_color%}"
+ assertEquals "$RESET_COLOR_CHANGES" "%{$reset_color%}"
+}
+
+set_env_vars() {
+ export GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead"
+ export GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind"
+ export GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged"
+ export GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream"
+
+ export GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead"
+ export GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind"
+ export GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged"
+
+ export GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged"
+ export GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged"
+ export GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted"
+ export GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked"
+
+ export GIT_RADAR_COLOR_BRANCH="branch-color"
+ export GIT_RADAR_MASTER_SYMBOL="m"
+
+ export GIT_RADAR_COLOR_LOCAL_RESET="local-reset"
+ export GIT_RADAR_COLOR_REMOTE_RESET="remote-reset"
+ export GIT_RADAR_COLOR_CHANGES_RESET="change-reset"
+ export GIT_RADAR_COLOR_BRANCH_RESET="branch-reset"
+}
+
+reset_env_vars() {
+ export GIT_RADAR_COLOR_REMOTE_AHEAD=""
+ export GIT_RADAR_COLOR_REMOTE_BEHIND=""
+ export GIT_RADAR_COLOR_REMOTE_DIVERGED=""
+ export GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM=""
+
+ export GIT_RADAR_COLOR_LOCAL_AHEAD=""
+ export GIT_RADAR_COLOR_LOCAL_BEHIND=""
+ export GIT_RADAR_COLOR_LOCAL_DIVERGED=""
+
+ export GIT_RADAR_COLOR_CHANGES_STAGED=""
+ export GIT_RADAR_COLOR_CHANGES_UNSTAGED=""
+ export GIT_RADAR_COLOR_CHANGES_CONFLICTED=""
+ export GIT_RADAR_COLOR_CHANGES_UNTRACKED=""
+
+ export GIT_RADAR_COLOR_BRANCH=""
+ export GIT_RADAR_MASTER_SYMBOL=""
+
+ export GIT_RADAR_COLOR_LOCAL_RESET=""
+ export GIT_RADAR_COLOR_REMOTE_RESET=""
+ export GIT_RADAR_COLOR_CHANGES_RESET=""
+ export GIT_RADAR_COLOR_BRANCH_RESET=""
+}
+
+create_rc_file() {
+ echo 'GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream"' >> .gitradarrc$1
+
+ echo 'GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged"' >> .gitradarrc$1
+
+ echo 'GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked"' >> .gitradarrc$1
+
+ echo 'export GIT_RADAR_COLOR_BRANCH="branch-color"' >> .gitradarrc$1
+ echo 'export GIT_RADAR_MASTER_SYMBOL="m"' >> .gitradarrc$1
+
+ echo 'GIT_RADAR_COLOR_LOCAL_RESET="local-reset"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_REMOTE_RESET="remote-reset"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_CHANGES_RESET="change-reset"' >> .gitradarrc$1
+ echo 'GIT_RADAR_COLOR_BRANCH_RESET="branch-reset"' >> .gitradarrc$1
+}
+
+test_with_rcfile_bash() {
+ reset_env_vars
+ cd_to_tmp
+
+ rcfile_path="$(pwd)"
+
+ create_rc_file ".bash"
+ prepare_bash_colors
+
+ assertEquals "$COLOR_REMOTE_AHEAD" "\x01remote-ahead\x02"
+ assertEquals "$COLOR_REMOTE_BEHIND" "\x01remote-behind\x02"
+ assertEquals "$COLOR_REMOTE_DIVERGED" "\x01remote-diverged\x02"
+ assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "\x01not-upstream\x02"
+
+ assertEquals "$COLOR_LOCAL_AHEAD" "\x01local-ahead\x02"
+ assertEquals "$COLOR_LOCAL_BEHIND" "\x01local-behind\x02"
+ assertEquals "$COLOR_LOCAL_DIVERGED" "\x01local-diverged\x02"
+
+ assertEquals "$COLOR_CHANGES_STAGED" "\x01changes-staged\x02"
+ assertEquals "$COLOR_CHANGES_UNSTAGED" "\x01changes-unstaged\x02"
+ assertEquals "$COLOR_CHANGES_CONFLICTED" "\x01changes-conflicted\x02"
+ assertEquals "$COLOR_CHANGES_UNTRACKED" "\x01changes-untracked\x02"
+
+ assertEquals "$COLOR_BRANCH" "\x01branch-color\x02"
+ assertEquals "$MASTER_SYMBOL" "m"
+
+ assertEquals "$RESET_COLOR_LOCAL" "\x01local-reset\x02"
+ assertEquals "$RESET_COLOR_REMOTE" "\x01remote-reset\x02"
+ assertEquals "$RESET_COLOR_CHANGES" "\x01change-reset\x02"
+ assertEquals "$RESET_COLOR_BRANCH" "\x01branch-reset\x02"
+
+ rm_tmp
+}
+
+test_with_rcfile_zsh() {
+ reset_env_vars
+ cd_to_tmp
+
+ rcfile_path="$(pwd)"
+
+ create_rc_file ".zsh"
+ mock_zsh_colors
+ prepare_zsh_colors
+
+ assertEquals "$COLOR_REMOTE_AHEAD" "%{remote-ahead%}"
+ assertEquals "$COLOR_REMOTE_BEHIND" "%{remote-behind%}"
+ assertEquals "$COLOR_REMOTE_DIVERGED" "%{remote-diverged%}"
+ assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "%{not-upstream%}"
+
+ assertEquals "$COLOR_LOCAL_AHEAD" "%{local-ahead%}"
+ assertEquals "$COLOR_LOCAL_BEHIND" "%{local-behind%}"
+ assertEquals "$COLOR_LOCAL_DIVERGED" "%{local-diverged%}"
+
+ assertEquals "$COLOR_CHANGES_STAGED" "%{changes-staged%}"
+ assertEquals "$COLOR_CHANGES_UNSTAGED" "%{changes-unstaged%}"
+ assertEquals "$COLOR_CHANGES_CONFLICTED" "%{changes-conflicted%}"
+ assertEquals "$COLOR_CHANGES_UNTRACKED" "%{changes-untracked%}"
+
+ assertEquals "$COLOR_BRANCH" "%{branch-color%}"
+ assertEquals "$MASTER_SYMBOL" "m"
+
+ assertEquals "$RESET_COLOR_LOCAL" "%{local-reset%}"
+ assertEquals "$RESET_COLOR_REMOTE" "%{remote-reset%}"
+ assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}"
+ assertEquals "$RESET_COLOR_BRANCH" "%{branch-reset%}"
+
+ rm_tmp
+}
+
+test_with_env_vars_bash() {
+ reset_env_vars
+ set_env_vars
+ prepare_bash_colors
+
+ assertEquals "$COLOR_REMOTE_AHEAD" "\x01remote-ahead\x02"
+ assertEquals "$COLOR_REMOTE_BEHIND" "\x01remote-behind\x02"
+ assertEquals "$COLOR_REMOTE_DIVERGED" "\x01remote-diverged\x02"
+ assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "\x01not-upstream\x02"
+
+ assertEquals "$COLOR_LOCAL_AHEAD" "\x01local-ahead\x02"
+ assertEquals "$COLOR_LOCAL_BEHIND" "\x01local-behind\x02"
+ assertEquals "$COLOR_LOCAL_DIVERGED" "\x01local-diverged\x02"
+
+ assertEquals "$COLOR_CHANGES_STAGED" "\x01changes-staged\x02"
+ assertEquals "$COLOR_CHANGES_UNSTAGED" "\x01changes-unstaged\x02"
+ assertEquals "$COLOR_CHANGES_CONFLICTED" "\x01changes-conflicted\x02"
+ assertEquals "$COLOR_CHANGES_UNTRACKED" "\x01changes-untracked\x02"
+
+ assertEquals "$COLOR_BRANCH" "\x01branch-color\x02"
+ assertEquals "$MASTER_SYMBOL" "m"
+
+ assertEquals "$RESET_COLOR_LOCAL" "\x01local-reset\x02"
+ assertEquals "$RESET_COLOR_REMOTE" "\x01remote-reset\x02"
+ assertEquals "$RESET_COLOR_CHANGES" "\x01change-reset\x02"
+ assertEquals "$RESET_COLOR_BRANCH" "\x01branch-reset\x02"
+}
+
+test_with_env_vars_zsh() {
+ reset_env_vars
+ set_env_vars
+ mock_zsh_colors
+ prepare_zsh_colors
+
+ assertEquals "$COLOR_REMOTE_AHEAD" "%{remote-ahead%}"
+ assertEquals "$COLOR_REMOTE_BEHIND" "%{remote-behind%}"
+ assertEquals "$COLOR_REMOTE_DIVERGED" "%{remote-diverged%}"
+ assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "%{not-upstream%}"
+
+ assertEquals "$COLOR_LOCAL_AHEAD" "%{local-ahead%}"
+ assertEquals "$COLOR_LOCAL_BEHIND" "%{local-behind%}"
+ assertEquals "$COLOR_LOCAL_DIVERGED" "%{local-diverged%}"
+
+ assertEquals "$COLOR_CHANGES_STAGED" "%{changes-staged%}"
+ assertEquals "$COLOR_CHANGES_UNSTAGED" "%{changes-unstaged%}"
+ assertEquals "$COLOR_CHANGES_CONFLICTED" "%{changes-conflicted%}"
+ assertEquals "$COLOR_CHANGES_UNTRACKED" "%{changes-untracked%}"
+
+ assertEquals "$COLOR_BRANCH" "%{branch-color%}"
+ assertEquals "$MASTER_SYMBOL" "m"
+
+ assertEquals "$RESET_COLOR_LOCAL" "%{local-reset%}"
+ assertEquals "$RESET_COLOR_REMOTE" "%{remote-reset%}"
+ assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}"
+ assertEquals "$RESET_COLOR_BRANCH" "%{branch-reset%}"
+}
+
+test_bash_colors_local() {
+ reset_env_vars
+ set_env_vars
+ prepare_bash_colors
+
+ cd_to_tmp "remote"
+ git init --bare --quiet
+ remoteLocation="$(pwd)"
+
+ cd_to_tmp "repo"
+ git init --quiet
+ git remote add origin $remoteLocation
+ git fetch origin --quiet
+ git checkout -b master --quiet
+ touch README
+ git add README
+ git commit -m "initial commit" --quiet
+ git push --quiet -u origin master >/dev/null
+ repoLocation="$(pwd)"
+
+ echo "foo" > foo
+ git add .
+ git commit -m "test commit" --quiet
+
+ printf -v expected " 1\x01local-ahead\x02↑\x01local-reset\x02"
+ assertEquals "$expected" "$(bash_color_local_commits)"
+ assertEquals "$expected" "$(color_local_commits)"
+
+ git push --quiet >/dev/null
+ git reset --hard head^ --quiet >/dev/null
+
+ printf -v expected " 1\x01local-behind\x02↓\x01local-reset\x02"
+ assertEquals "$expected" "$(bash_color_local_commits)"
+ assertEquals "$expected" "$(color_local_commits)"
+
+ echo "foo" > foo
+ git add .
+ git commit -m "new commit" --quiet
+
+ printf -v expected " 1\x01local-diverged\x02⇵\x01local-reset\x021"
+ assertEquals "$expected" "$(bash_color_local_commits)"
+ assertEquals "$expected" "$(color_local_commits)"
+
+ rm_tmp
+}
+
+test_zsh_colors_local() {
+ reset_env_vars
+ set_env_vars
+ prepare_zsh_colors
+
+ cd_to_tmp "remote"
+ git init --bare --quiet
+ remoteLocation="$(pwd)"
+
+ cd_to_tmp "repo"
+ git init --quiet
+ git remote add origin $remoteLocation
+ git fetch origin --quiet
+ git checkout -b master --quiet
+ touch README
+ git add README
+ git commit -m "initial commit" --quiet
+ git push --quiet -u origin master >/dev/null
+ repoLocation="$(pwd)"
+
+ echo "foo" > foo
+ git add .
+ git commit -m "test commit" --quiet
+
+ assertEquals " 1%{local-ahead%}↑%{local-reset%}" "$(zsh_color_local_commits)"
+
+ git push --quiet >/dev/null
+ git reset --hard head^ --quiet >/dev/null
+
+ assertEquals " 1%{local-behind%}↓%{local-reset%}" "$(zsh_color_local_commits)"
+
+ echo "foo" > foo
+ git add .
+ git commit -m "new commit" --quiet
+
+ assertEquals " 1%{local-diverged%}⇵%{local-reset%}1" "$(zsh_color_local_commits)"
+
+ rm_tmp
+}
+
+test_bash_colors_remote() {
+ reset_env_vars
+ set_env_vars
+ prepare_bash_colors
+
+ cd_to_tmp "remote"
+ git init --bare --quiet
+ remoteLocation="$(pwd)"
+
+ cd_to_tmp "repo"
+ git init --quiet
+ git remote add origin $remoteLocation
+ git fetch origin --quiet
+ git checkout -b master --quiet
+ touch README
+ git add README
+ git commit -m "initial commit" --quiet
+ echo "foo" > foo
+ git add .
+ git commit -m "test commit" --quiet
+ git push --quiet -u origin master >/dev/null
+ repoLocation="$(pwd)"
+
+ git reset --hard head^ --quiet >/dev/null
+ git checkout -b mybranch --quiet
+ git push --quiet -u origin mybranch >/dev/null
+
+ printf -v expected "m 1 \x01remote-behind\x02→\x01remote-reset\x02 "
+ assertEquals "$expected" "$(bash_color_remote_commits)"
+ assertEquals "$expected" "$(color_remote_commits)"
+
+ echo "bar" > bar
+ git add .
+ git commit -m "new commit" --quiet
+ git push --quiet >/dev/null
+
+ printf -v expected "m 1 \x01remote-diverged\x02⇄\x01remote-reset\x02 1 "
+ assertEquals "$expected" "$(bash_color_remote_commits)"
+ assertEquals "$expected" "$(color_remote_commits)"
+
+ git pull origin master --quiet >/dev/null
+ git push --quiet >/dev/null
+
+ printf -v expected "m \x01remote-ahead\x02←\x01remote-reset\x02 2 "
+ assertEquals "$expected" "$(bash_color_remote_commits)"
+ assertEquals "$expected" "$(color_remote_commits)"
+
+ rm_tmp
+}
+
+test_zsh_colors_remote() {
+ reset_env_vars
+ set_env_vars
+ prepare_zsh_colors
+
+ cd_to_tmp "remote"
+ git init --bare --quiet
+ remoteLocation="$(pwd)"
+
+ cd_to_tmp "repo"
+ git init --quiet
+ git remote add origin $remoteLocation
+ git fetch origin --quiet
+ git checkout -b master --quiet
+ touch README
+ git add README
+ git commit -m "initial commit" --quiet
+ echo "foo" > foo
+ git add .
+ git commit -m "test commit" --quiet
+ git push --quiet -u origin master >/dev/null
+ repoLocation="$(pwd)"
+
+ git reset --hard head^ --quiet >/dev/null
+ git checkout -b mybranch --quiet
+ git push --quiet -u origin mybranch >/dev/null
+
+ assertEquals "m 1 %{remote-behind%}→%{remote-reset%} " "$(zsh_color_remote_commits)"
+
+ echo "bar" > bar
+ git add .
+ git commit -m "new commit" --quiet
+ git push --quiet >/dev/null
+
+ assertEquals "m 1 %{remote-diverged%}⇄%{remote-reset%} 1 " "$(zsh_color_remote_commits)"
+
+ git pull origin master --quiet >/dev/null
+ git push --quiet >/dev/null
+
+ assertEquals "m %{remote-ahead%}←%{remote-reset%} 2 " "$(zsh_color_remote_commits)"
+
+ rm_tmp
+}
+
+test_bash_colors_changes() {
+ reset_env_vars
+ set_env_vars
+ prepare_bash_colors
+
+ cd_to_tmp
+ git init --quiet
+
+ touch foo
+ touch bar
+ git add bar
+ echo "bar" > bar
+ untracked="1\x01changes-untracked\x02A\x01change-reset\x02"
+ unstaged="1\x01changes-unstaged\x02M\x01change-reset\x02"
+ staged="1\x01changes-staged\x02A\x01change-reset\x02"
+
+ printf -v expected " $staged $unstaged $untracked"
+ assertEquals "$expected" "$(bash_color_changes_status)"
+ assertEquals "$expected" "$(color_changes_status)"
+ rm_tmp
+}
+
+test_zsh_colors_changes() {
+ reset_env_vars
+ set_env_vars
+ prepare_zsh_colors
+
+ cd_to_tmp
+ git init --quiet
+
+ touch foo
+ touch bar
+ git add bar
+ echo "bar" > bar
+ untracked="1%{changes-untracked%}A%{change-reset%}"
+ unstaged="1%{changes-unstaged%}M%{change-reset%}"
+ staged="1%{changes-staged%}A%{change-reset%}"
+
+ assertEquals " $staged $unstaged $untracked" "$(zsh_color_changes_status)"
+ rm_tmp
+}
+
+. ./shunit/shunit2
diff --git a/test-commits.sh b/test-commits.sh
index 89a1ba1..8eecffc 100755
--- a/test-commits.sh
+++ b/test-commits.sh
@@ -367,19 +367,16 @@ 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 "\x01\033[1;32m\x02↑\x01\033[0m\x02"
- printf -v bash_both "\x01\033[1;33m\x02⇵\x01\033[0m\x02"
- printf -v bash_down "\x01\033[1;31m\x02↓\x01\033[0m\x02"
+test_local_commits() {
+ local up="↑"
+ local both="⇵"
+ local down="↓"
cd_to_tmp "remote"
assertEquals "" "$(zsh_color_local_commits)"
assertEquals "" "$(bash_color_local_commits)"
+ assertEquals "" "$(color_local_commits)"
git init --quiet
touch README
@@ -396,14 +393,16 @@ test_zsh_and_bash_local_commits() {
assertEquals "" "$(zsh_color_local_commits)"
assertEquals "" "$(bash_color_local_commits)"
+ assertEquals "" "$(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)"
+ assertEquals " 1$up" "$(zsh_color_local_commits)"
+ assertEquals " 1$up" "$(bash_color_local_commits)"
+ assertEquals " 1$up" "$(color_local_commits)"
cd "$remote"
echo "foo" > foo
@@ -413,13 +412,15 @@ test_zsh_and_bash_local_commits() {
cd "$repo"
git fetch origin --quiet
- assertEquals " 1${zsh_both}1" "$(zsh_color_local_commits)"
- assertEquals " 1${bash_both}1" "$(bash_color_local_commits)"
+ assertEquals " 1${both}1" "$(zsh_color_local_commits)"
+ assertEquals " 1${both}1" "$(bash_color_local_commits)"
+ assertEquals " 1${both}1" "$(color_local_commits)"
git reset --hard HEAD^ --quiet
- assertEquals " 1$zsh_down" "$(zsh_color_local_commits)"
- assertEquals " 1$bash_down" "$(bash_color_local_commits)"
+ assertEquals " 1$down" "$(zsh_color_local_commits)"
+ assertEquals " 1$down" "$(bash_color_local_commits)"
+ assertEquals " 1$down" "$(color_local_commits)"
}
. ./shunit/shunit2
diff --git a/test-radar-base.sh b/test-radar-base.sh
new file mode 100755
index 0000000..9f7f8ee
--- /dev/null
+++ b/test-radar-base.sh
@@ -0,0 +1,28 @@
+scriptDir="$(cd "$(dirname "$0")"; pwd)"
+
+source "$scriptDir/radar-base.sh"
+
+test_show_remote_status() {
+ show_remote_status
+ assertTrue $?
+
+ show_remote_status --bash
+ assertTrue $?
+
+ show_remote_status --bash --fetch
+ assertTrue $?
+
+ show_remote_status --bash --no-remote-status --fetch
+ assertFalse $?
+
+ show_remote_status --bash --fetch --no-remote-status
+ assertFalse $?
+
+ show_remote_status --no-remote-status --bash --fetch
+ assertFalse $?
+
+ show_remote_status --bash --fetch --minimal --no-remote-status
+ assertFalse $?
+}
+
+. ./shunit/shunit2 \ No newline at end of file