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
|
2017-01-06 22:18:44 +00:00
|
|
|
Exit with 1
|
2016-03-24 00:18:33 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
#; 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
|
2017-01-06 22:18:44 +00:00
|
|
|
[ "$status" -eq 1 ]
|
2016-03-24 00:18:33 +00:00
|
|
|
[[ "$output" =~ .bogus..is.not.a.git.command ]]
|
|
|
|
}
|
|
|
|
|
2017-01-06 22:18:44 +00:00
|
|
|
@test "Git command 'add' - badfile" {
|
|
|
|
echo "
|
|
|
|
When the command 'add' is provided
|
|
|
|
And the file specified does not exist
|
|
|
|
Exit with 128
|
|
|
|
"
|
|
|
|
|
|
|
|
#; start fresh
|
|
|
|
setup_environment
|
|
|
|
|
|
|
|
#; define a non existig testfile
|
|
|
|
local testfile="$T_DIR_WORK/does_not_exist"
|
|
|
|
|
|
|
|
#; run add
|
|
|
|
run "${T_YADM_Y[@]}" add -v "$testfile"
|
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 128 ]
|
|
|
|
[[ "$output" =~ pathspec.+did.not.match ]]
|
|
|
|
}
|
|
|
|
|
2016-03-24 00:18:33 +00:00
|
|
|
@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 ]]
|
|
|
|
}
|