Update tests

This commit is contained in:
Ilan Cosman 2020-06-30 17:34:57 -07:00
parent 4d705b653a
commit db1a859bed
8 changed files with 27 additions and 18 deletions

View File

@ -5,7 +5,9 @@ function _tide_pwd
set -g _tide_pwd_output $colorDirs$_tide_pwd
if not test -w $PWD
set -p _tide_pwd_output $colorDirs{$tide_pwd_unwritable_icon}
if test -n "$tide_pwd_unwritable_icon"
set _tide_pwd_output "$tide_pwd_unwritable_icon "$_tide_pwd_output
end
end
set -l truncatedList '.' $_tide_split_pwd

View File

@ -12,6 +12,8 @@ function tide_test
set -l failed '/tmp/tide_test_failed'
set -l passed '/tmp/tide_test_passed'
set -l returnStatement 0
if set -q _flag_all
set argv (basename -s '.fish' $testsDir/*)
end
@ -39,10 +41,15 @@ function tide_test
printf '%s\n' '--------FAILED--------'
cat $failed
rm $failed
set returnStatement 1
end
if test -e $pending
rm $pending
end
return $returnStatement
end
function _help

View File

@ -15,6 +15,6 @@ function _tide_item_cmd_duration
end
set_color $tide_cmd_duration_color
printf '%s' {$hours}'h' {$minutes}'m' {$seconds}'s'
printf '%s' {$hours}'h ' {$minutes}'m ' {$seconds}'s'
end
end

View File

@ -9,6 +9,6 @@ function _cmd_duration -a duration threshold decimals
end
@test 'Less than threshold' (_cmd_duration 2000 3000 0) -z
@test 'Decimals' (_cmd_duration 4567 3000 3) = '4.567s '
@test 'Minutes' (_cmd_duration 456700 3000 0) = '7m 36s '
@test 'Hours' (_cmd_duration 4567000 3000 0) = '1h 16m 7s '
@test 'Decimals' (_cmd_duration 4567 3000 3) = '4.567s'
@test 'Minutes' (_cmd_duration 456700 3000 0) = '7m 36s'
@test 'Hours' (_cmd_duration 4567000 3000 0) = '1h 16m 7s'

View File

@ -7,5 +7,5 @@ function _context
end
@test 'None' (_context) -z
@test 'SSH' (set -g SSH_TTY 'true'; _context) = $USER'@'$hostname' '
@test 'Root' (_tide_decolor (sudo fish -c "source $sourceFile;_tide_item_context")) = 'root@'$hostname' '
@test 'SSH' (set -g SSH_TTY 'true'; _context) = $USER'@'$hostname
@test 'Root' (_tide_decolor (sudo fish -c "source $sourceFile;_tide_item_context")) = 'root@'$hostname

View File

@ -5,4 +5,4 @@ function _jobs
end
@test 'No Jobs' (_jobs) -z
@test 'Jobs' (sleep 60 &; _jobs) = "$tide_jobs_icon "
@test 'Jobs' (sleep 60 &; _jobs) = "$tide_jobs_icon"

View File

@ -7,16 +7,16 @@ end
set -l unwr "$tide_pwd_unwritable_icon "
@test '/' (_pwd '/') = $unwr'/ '
@test '/usr' (_pwd '/usr') = $unwr'/usr '
@test '/usr/share' (_pwd '/usr/share') = $unwr'/usr/share '
@test '~' (_pwd "$HOME") = '~ '
@test '~/.config' (_pwd "$HOME/.config") = '~/.config '
@test '~/.config/fish' (_pwd "$HOME/.config/fish") = '~/.config/fish '
@test '/' (_pwd '/') = $unwr'/'
@test '/usr' (_pwd '/usr') = $unwr'/usr'
@test '/usr/share' (_pwd '/usr/share') = $unwr'/usr/share'
@test '~' (_pwd "$HOME") = '~'
@test '~/.config' (_pwd "$HOME/.config") = '~/.config'
@test '~/.config/fish' (_pwd "$HOME/.config/fish") = '~/.config/fish'
set -l longDir "$HOME/alfa/bravo/charlie/delta/echo/foxtrot/golf/hotel/inda/juliett/kilo/lima/mike/november/oscar/papa"
if not test -e $longDir
mkdir -p $longDir
end
@test 'Long dir' (_pwd "$longDir") = '~/a/b/c/d/e/f/golf/hotel/inda/juliett/kilo/lima/mike/november/oscar/papa '
@test 'Long dir' (_pwd "$longDir") = '~/a/b/c/d/e/f/g/hotel/inda/juliett/kilo/lima/mike/november/oscar/papa'
rm -r $longDir

View File

@ -8,7 +8,7 @@ end
@test 'true' (true; _status) -z
@test 'false' (false; _status) -z
@test 'true|false' (true|false; _status) = "$tide_status_failure_icon 0|1 "
@test 'true|false' (true|false; _status) = "$tide_status_failure_icon 0|1"
@test 'true|true' (true|true; _status) -z
@test 'false|true' (false|true; _status) = "$tide_status_success_icon 1|0 "
@test 'false|false' (false|false; _status) = "$tide_status_failure_icon 1|1 "
@test 'false|true' (false|true; _status) = "$tide_status_success_icon 1|0"
@test 'false|false' (false|false; _status) = "$tide_status_failure_icon 1|1"