Add tests for enter
command
This commit is contained in:
parent
4e05be7020
commit
6974e4ce8c
1 changed files with 66 additions and 0 deletions
66
test/114_accept_enter.bats
Normal file
66
test/114_accept_enter.bats
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
load common
|
||||||
|
load_fixtures
|
||||||
|
status=;output=; #; populated by bats run()
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
build_repo
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Command 'enter' (SHELL not set)" {
|
||||||
|
echo "
|
||||||
|
When 'enter' command is provided,
|
||||||
|
And SHELL is not set
|
||||||
|
Report error
|
||||||
|
Exit with 1
|
||||||
|
"
|
||||||
|
|
||||||
|
SHELL=
|
||||||
|
export SHELL
|
||||||
|
run "${T_YADM_Y[@]}" enter
|
||||||
|
|
||||||
|
#; validate status and output
|
||||||
|
[ $status -eq 1 ]
|
||||||
|
[[ "$output" =~ does.not.refer.to.an.executable ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Command 'enter' (SHELL not executable)" {
|
||||||
|
echo "
|
||||||
|
When 'enter' command is provided,
|
||||||
|
And SHELL is not executable
|
||||||
|
Report error
|
||||||
|
Exit with 1
|
||||||
|
"
|
||||||
|
|
||||||
|
touch "$T_TMP/badshell"
|
||||||
|
SHELL="$T_TMP/badshell"
|
||||||
|
export SHELL
|
||||||
|
run "${T_YADM_Y[@]}" enter
|
||||||
|
|
||||||
|
#; validate status and output
|
||||||
|
[ $status -eq 1 ]
|
||||||
|
[[ "$output" =~ does.not.refer.to.an.executable ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Command 'enter' (SHELL executable)" {
|
||||||
|
echo "
|
||||||
|
When 'enter' command is provided,
|
||||||
|
And SHELL is set
|
||||||
|
Execute SHELL command
|
||||||
|
Expose GIT variables
|
||||||
|
Set prompt variables
|
||||||
|
Announce entering/leaving shell
|
||||||
|
Exit with 0
|
||||||
|
"
|
||||||
|
|
||||||
|
SHELL=$(command -v env)
|
||||||
|
export SHELL
|
||||||
|
run "${T_YADM_Y[@]}" enter
|
||||||
|
|
||||||
|
#; validate status and output
|
||||||
|
[ $status -eq 0 ]
|
||||||
|
[[ "$output" =~ GIT_DIR= ]]
|
||||||
|
[[ "$output" =~ PROMPT=yadm.shell ]]
|
||||||
|
[[ "$output" =~ PS1=yadm.shell ]]
|
||||||
|
[[ "$output" =~ Entering.yadm.repo ]]
|
||||||
|
[[ "$output" =~ Leaving.yadm.repo ]]
|
||||||
|
}
|
Loading…
Reference in a new issue