test(fedit): more coverage for fedit

pull/13/head
kevin zhuang 4 years ago
parent 52212228f9
commit 1fba34230d

@ -48,7 +48,7 @@ while [[ "$#" -gt 0 ]]; do
exit 0
;;
*)
echo "Invalid option $1" >&2
echo "Invalid option: $1" >&2
usage
exit 1
;;
@ -56,7 +56,7 @@ while [[ "$#" -gt 0 ]]; do
done
if [[ "${edit_type}" == "commit" ]]; then
selected_commit=$(get_commit "Select a commit to rename")
selected_commit=$(get_commit "select a commit to rename")
[[ -z "${selected_commit}" ]] && exit 1
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" rebase -i "${selected_commit}"~
else

@ -13,6 +13,16 @@ no_file_selected() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fedit -m
}
edit_commits() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare fedit --commit
}
edit_files() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare fedit
}
@test "fedit help" {
run help
[ "${status}" -eq 0 ]
@ -22,10 +32,25 @@ no_file_selected() {
@test "fedit invalid option" {
run invalid_option
[ "${status}" -eq 1 ]
[ "${lines[0]}" = "Invalid option: p" ]
[ "${lines[0]}" = "Invalid option: -p" ]
}
@test "fedit no file selected" {
run no_file_selected
[ "${status}" -eq 1 ]
}
@test "fedit edit commits" {
run edit_commits
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
skip
fi
[ "${status}" -eq 128 ]
[ "${lines[0]}" = "fatal: invalid upstream 'commitdiff~'" ]
}
@test "fedit edit files" {
run edit_files
[ "${status}" -eq 1 ]
[ -z "${output}" ]
}

@ -29,6 +29,8 @@ elif [[ "$*" =~ '--multi --preview ' ]] && [[ "$*" =~ "tree -L 1 -C --dirsfirst
echo "searchdir"
elif [[ "$*" =~ '--header=select the target commit' ]] && [[ "$*" =~ "diff --color" ]]; then
echo "commitdiff"
elif [[ "$*" =~ "--no-multi --header=select a commit to rename" ]] && [[ "$*" =~ "show --color=always" ]]; then
echo "commitdiff"
elif [[ "$*" =~ '--multi --preview ' ]] && [[ "$*" =~ "cat {}" ]]; then
echo "searchfile"
elif [[ "$*" =~ "--header=select a file to checkout version in HEAD" ]] && [[ "$*" =~ "diff HEAD --color=always" ]]; then
@ -37,4 +39,6 @@ elif [[ "$*" =~ '--header=select files to stage' ]] && [[ "$*" =~ "diff HEAD --c
echo "-- modifiedfile"
elif [[ "$*" =~ "--header=select files to unstage" ]] && [[ "$*" =~ "diff HEAD --color=always" ]]; then
echo "-- modifiedfile"
elif [[ "$*" =~ "--header=select tracked files to edit" ]]; then
exit
fi

Loading…
Cancel
Save