2
0
mirror of https://github.com/kazhala/dotbare synced 2024-11-17 21:25:32 +00:00

test(freset): more test coverage

This commit is contained in:
kevin zhuang 2020-06-22 11:19:27 +10:00
parent f58c382586
commit f61a9ce9de
2 changed files with 36 additions and 3 deletions

View File

@ -27,7 +27,7 @@ source "${mydir}"/../helper/get_confirmation.sh
source "${mydir}"/../helper/git_query.sh
function usage() {
echo -e "Usage: dotbare freset [-h] [-a] [-c] [-S] [-H] ...\n"
echo -e "Usage: dotbare freset [-h] [-c] [-S] [-H] [-y] ...\n"
echo -e "Reset/Unstage the selected staged file"
echo -e "Or reset the HEAD to certain commits by using -c flag\n"
echo -e "Default: unstage the selected files\n"

View File

@ -8,14 +8,47 @@ invalid_option() {
bash "${BATS_TEST_DIRNAME}"/../dotbare freset -p
}
no_selection_made() {
bash "${BATS_TEST_DIRNAME}"/../dotbare freset
}
select_commit() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare freset --commit -y
}
select_files() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare freset
}
@test "freset help" {
run help
[ "${status}" -eq 0 ]
[ "${lines[0]}" = "Usage: dotbare freset [-h] [-a] [-c] [-S] [-H] ..." ]
[ "${lines[0]}" = "Usage: dotbare freset [-h] [-c] [-S] [-H] [-y] ..." ]
}
@test "freset invalid option" {
run invalid_option
[ "${status}" -eq 1 ]
[ "${lines[0]}" = "Invalid option: p" ]
[ "${lines[0]}" = "Invalid option: -p" ]
}
@test "freset select commit" {
run select_commit
result=$(echo "${lines[0]}" | tr '`' "'")
[ "${status}" -eq 129 ]
[ "${result}" = "error: unknown option 'no-multi'" ]
}
@test "freset no selection made" {
run no_selection_made
[ -z "${output}" ]
[ "${status}" -eq 1 ]
}
@test "freset select files" {
run select_files
[ -z "${output}" ]
[ "${status}" -eq 0 ]
}