diff options
author | Michael Allen <michael@michaelallen.io> | 2015-08-30 16:59:21 +0100 |
---|---|---|
committer | Michael Allen <michael@michaelallen.io> | 2015-08-30 16:59:21 +0100 |
commit | 4cc2298359b8e2ac4fb0c3a4f061737551e5bb1e (patch) | |
tree | d3f8341cb1fc7b70d16402d53642cb522954202b | |
parent | 0a471db63edcb0ba1fcfb6792e51b791de3fcb81 (diff) | |
download | git-sonar-4cc2298359b8e2ac4fb0c3a4f061737551e5bb1e.tar.gz git-sonar-4cc2298359b8e2ac4fb0c3a4f061737551e5bb1e.zip |
Test zsh ability to override colors
-rwxr-xr-x | test-colors.sh | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/test-colors.sh b/test-colors.sh new file mode 100755 index 0000000..712dad5 --- /dev/null +++ b/test-colors.sh @@ -0,0 +1,89 @@ +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_zsh() { + 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%}" +} + +test_with_env_vars_zsh() { + 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_LOCAL_RESET="local-reset" + export GIT_RADAR_COLOR_REMOTE_RESET="remote-reset" + export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" + + 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 "$RESET_COLOR_LOCAL" "%{local-reset%}" + assertEquals "$RESET_COLOR_REMOTE" "%{remote-reset%}" + assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}" +} + +. ./shunit/shunit2 |