1
0
Fork 0
mirror of synced 2024-12-22 06:31:07 -05:00
yadm/test/114_accept_enter.bats
2017-03-30 16:30:39 -05:00

66 lines
1.3 KiB
Bash

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 ]]
}