Skip to content

Commit

Permalink
Fix git dirty tests
Browse files Browse the repository at this point in the history
These tests run in sequence in the same directory, they are not
isolated. Tests need to take account of changes to the directory state
made by previous tests.
  • Loading branch information
spthm committed Jul 15, 2023
1 parent b21a72a commit 27e7ffa
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions tests/_pure_prompt_git_dirty.test.fish
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,50 @@ end

@test "_pure_prompt_git_dirty: untracked files in empty repo marked as dirty" (
touch file.txt

set --universal pure_symbol_git_dirty '*'

_pure_prompt_git_dirty
) = '*'

@test "_pure_prompt_git_dirty: staged files in empty repo marked as dirty" (
touch file.txt
echo "staged" >> file.txt
git add file.txt

set --universal pure_symbol_git_dirty '*'

_pure_prompt_git_dirty
) = '*'

@test "_pure_prompt_git_dirty: clean is not marked as dirty" (
touch init.txt
git add init.txt
git commit --quiet --message 'initial commit'
echo "clean" >> file.txt
git add file.txt
git commit --quiet --message 'commit staged files'

set --universal pure_symbol_git_dirty '*'

_pure_prompt_git_dirty
) = ''

@test "_pure_prompt_git_dirty: untracked files mark git repo as dirty" (
touch init.txt
git add init.txt
git commit --quiet --message 'initial commit'
touch file_2.txt

touch file.txt
set --universal pure_symbol_git_dirty '*'

_pure_prompt_git_dirty
) = '*'

@test "_pure_prompt_git_dirty: staged files mark git repo as dirty" (
touch init.txt
git add init.txt
git commit --quiet --message 'initial commit'
echo "staged" >> file_2.txt
git add file_2.txt

touch file.txt
git add file.txt
set --universal pure_symbol_git_dirty '*'

_pure_prompt_git_dirty
) = '*'

@test "_pure_prompt_git_dirty: symbol is colorized" (
touch file.txt
echo "colorized" >> file.txt

source (dirname (status filename))/../functions/_pure_set_color.fish # enable colors
set --universal pure_symbol_git_dirty '*'
Expand Down

0 comments on commit 27e7ffa

Please sign in to comment.