2016-03-24 00:18:33 +00:00
|
|
|
load common
|
|
|
|
load_fixtures
|
2016-04-06 17:33:42 +00:00
|
|
|
status=;output=;lines=; #; populated by bats run()
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
IN_REPO=(.bash_profile .vimrc)
|
|
|
|
|
|
|
|
function setup_environment() {
|
|
|
|
destroy_tmp
|
|
|
|
build_repo "${IN_REPO[@]}"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Passthru unknown commands to Git" {
|
|
|
|
echo "
|
|
|
|
When the command 'bogus' is provided
|
|
|
|
Report bogus is not a command
|
|
|
|
Exit with 0
|
|
|
|
"
|
|
|
|
|
|
|
|
#; start fresh
|
|
|
|
setup_environment
|
|
|
|
|
|
|
|
#; run bogus
|
2016-04-06 17:33:42 +00:00
|
|
|
run "${T_YADM_Y[@]}" bogus
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ .bogus..is.not.a.git.command ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Git command 'add'" {
|
|
|
|
echo "
|
|
|
|
When the command 'add' is provided
|
|
|
|
Files are added to the index
|
|
|
|
Exit with 0
|
|
|
|
"
|
|
|
|
|
|
|
|
#; start fresh
|
|
|
|
setup_environment
|
|
|
|
|
|
|
|
#; create a testfile
|
|
|
|
local testfile="$T_DIR_WORK/testfile"
|
2016-04-06 17:33:42 +00:00
|
|
|
echo "$testfile" > "$testfile"
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; run add
|
2016-04-06 17:33:42 +00:00
|
|
|
run "${T_YADM_Y[@]}" add -v "$testfile"
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "add 'testfile'" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Git command 'status'" {
|
|
|
|
echo "
|
|
|
|
When the command 'status' is provided
|
|
|
|
Added files are shown
|
|
|
|
Exit with 0
|
|
|
|
"
|
|
|
|
|
|
|
|
#; run status
|
2016-04-06 17:33:42 +00:00
|
|
|
run "${T_YADM_Y[@]}" status
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ new\ file:[[:space:]]+testfile ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Git command 'commit'" {
|
|
|
|
echo "
|
|
|
|
When the command 'commit' is provided
|
|
|
|
Index is commited
|
|
|
|
Exit with 0
|
|
|
|
"
|
|
|
|
|
|
|
|
#; run commit
|
2016-04-06 17:33:42 +00:00
|
|
|
run "${T_YADM_Y[@]}" commit -m 'Add testfile'
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "${lines[1]}" =~ 1\ file\ changed ]]
|
|
|
|
[[ "${lines[1]}" =~ 1\ insertion ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Git command 'log'" {
|
|
|
|
echo "
|
|
|
|
When the command 'log' is provided
|
|
|
|
Commits are shown
|
|
|
|
Exit with 0
|
|
|
|
"
|
|
|
|
|
|
|
|
#; run log
|
2016-04-06 17:33:42 +00:00
|
|
|
run "${T_YADM_Y[@]}" log --oneline
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "${lines[0]}" =~ Add\ testfile ]]
|
|
|
|
}
|