Skip to content

Commit

Permalink
test(git): add before/after_each hook to each test
Browse files Browse the repository at this point in the history
  • Loading branch information
edouard-lopez committed Aug 17, 2023
1 parent ab97024 commit f561ef0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/_pure_prompt_git_dirty.test.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source (dirname (status filename))/../functions/_pure_prompt_git_dirty.fish
@echo (_print_filename (status filename))


function before_all
function before_each
mkdir -p /tmp/pure_pure_prompt_git_dirty # prevent conflict between parallel test files
and cd /tmp/pure_pure_prompt_git_dirty

Expand All @@ -14,27 +14,31 @@ function before_all
_purge_configs
_disable_colors
end
before_all

function after_all
function after_each
rm -rf /tmp/pure_pure_prompt_git_dirty
end


before_each
@test "_pure_prompt_git_dirty: empty repo is not marked as dirty" (
set --universal pure_symbol_git_dirty '*'

_pure_prompt_git_dirty
) = ''
after_each

before_each
@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
) = '*'
after_each

before_each
@test "_pure_prompt_git_dirty: staged files in empty repo marked as dirty" (
echo "staged" >> file.txt
git add file.txt
Expand All @@ -43,7 +47,9 @@ end

_pure_prompt_git_dirty
) = '*'
after_each

before_each
@test "_pure_prompt_git_dirty: clean is not marked as dirty" (
echo "clean" >> file.txt
git add file.txt
Expand All @@ -53,15 +59,19 @@ end

_pure_prompt_git_dirty
) = ''
after_each

before_each
@test "_pure_prompt_git_dirty: untracked files mark git repo as dirty" (
touch file_2.txt

set --universal pure_symbol_git_dirty '*'

_pure_prompt_git_dirty
) = '*'
after_each

before_each
@test "_pure_prompt_git_dirty: staged files mark git repo as dirty" (
echo "staged" >> file_2.txt
git add file_2.txt
Expand All @@ -70,7 +80,9 @@ end

_pure_prompt_git_dirty
) = '*'
after_each

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

Expand All @@ -80,6 +92,4 @@ end

_pure_prompt_git_dirty
) = (set_color brblack)'*'


after_all
after_each

0 comments on commit f561ef0

Please sign in to comment.