test(flog): more coverage

pull/13/head
kevin zhuang 4 years ago
parent 35118aa1d1
commit beec6161c7

@ -25,7 +25,7 @@ source "${mydir}"/../helper/git_query.sh
source "${mydir}"/../helper/get_confirmation.sh
function usage() {
echo -e "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] ...\n"
echo -e "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] [-y] ...\n"
echo -e "Interactive log viewer with action menu"
echo -e "Action menu contains command including revert|reset|edit|checkout|exit\n"
echo -e "Default: list all commits and prompt a menu for user to take action on the selected commit\n"

@ -8,14 +8,43 @@ invalid_option() {
bash "${BATS_TEST_DIRNAME}"/../dotbare flog -p
}
menu() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare flog
}
reset() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare flog --reset -y
}
@test "flog help" {
run help
[ "${status}" -eq 0 ]
[ "${lines[0]}" = "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] ..." ]
[ "${lines[0]}" = "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] [-y] ..." ]
}
@test "flog invalid option" {
run invalid_option
[ "${status}" -eq 1 ]
[ "${lines[0]}" = "Invalid option: p" ]
[ "${lines[0]}" = "Invalid option: -p" ]
}
@test "flog check routing" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
skip
fi
run menu
[ "${status}" -eq 0 ]
}
@test "flog reset" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
skip
fi
run reset
[ "${status}" -eq 129 ]
result=$(echo "${lines[0]}" | tr '`' "'")
[[ "${result}" =~ "error: unknown option 'commitshow'" ]]
[[ "${output}" =~ "usage: git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]" ]]
}

@ -21,6 +21,8 @@ if [[ "$*" =~ "--header=select a commit to checkout" ]] && [[ "$*" =~ "show --co
echo "--commitshow"
elif [[ "$*" =~ '--no-multi --header=select the target commit for HEAD' ]] && [[ "$*" =~ "show --color" ]]; then
echo "--commitshow"
elif [[ "$*" =~ '--header=select a commit' ]] && [[ "$*" =~ "show --color" ]]; then
echo "--commitshow"
elif [[ "$*" =~ "--no-multi --header=select a branch to checkout" ]]; then
echo "--branch"
elif [[ "$*" =~ '--header=select a file to checkout' ]] && [[ "$*" =~ "cat" ]]; then
@ -43,4 +45,6 @@ elif [[ "$*" =~ "--header=select files to unstage" ]] && [[ "$*" =~ "diff HEAD -
echo "-- modifiedfile"
elif [[ "$*" =~ "--header=select tracked files to edit" ]]; then
exit
elif [[ "$*" =~ "--no-multi --header=commit --commitshow" ]]; then
echo "exit"
fi

Loading…
Cancel
Save