test(fgrep): update fgrep related test to include new options

pull/21/head
Kevin Zhuang 4 years ago
parent cc769f9968
commit a2409ce93c

@ -20,7 +20,7 @@ source "${mydir}"/../helper/set_variable.sh
source "${mydir}"/../helper/git_query.sh
function usage() {
echo -e "Usage: dotbare fgrep [-h] ...
echo -e "Usage: dotbare fgrep [-h] [-c] [-f] ...
Grep words within tracked files and select to edit matches.

@ -14,10 +14,32 @@ edit_lines() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fgrep
}
full_deli() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
export EDITOR="echo"
bash "${BATS_TEST_DIRNAME}"/../dotbare fgrep --full
}
option_deli() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
export EDITOR="echo"
bash "${BATS_TEST_DIRNAME}"/../dotbare fgrep --col 2
}
@test "fgrep option delimiter" {
run option_deli
[[ "${output}" =~ "--nth 2.. --header=select matches to edit" ]]
}
@test "fgrep full delimiter" {
run full_deli
[[ "${output}" =~ "--nth 1.. --header=select matches to edit" ]]
}
@test "fgrep help" {
run help
[ "${status}" -eq 0 ]
[ "${lines[0]}" = "Usage: dotbare fgrep [-h] ..." ]
[ "${lines[0]}" = "Usage: dotbare fgrep [-h] [-c] [-f] ..." ]
}
@test "fgrep invalid option" {
@ -28,5 +50,5 @@ edit_lines() {
@test "fgrep edit lines" {
run edit_lines
[[ "${output}" =~ "fgrep_words" ]]
[[ "${output}" =~ "--nth 3.. --header=select matches to edit" ]]
}

@ -60,9 +60,6 @@ elif [[ "$*" =~ '--header=select stash to delete' ]] && [[ "$*" =~ "show -p __ -
elif [[ "$*" =~ '--header=select stash to apply' ]] && [[ "$*" =~ "show -p __ --color=always" ]]; then
# dotbare fstash -- "./fstash.bats" @test "fstash apply stash"
echo "fstash_apply"
elif [[ "$*" =~ '--delimiter : --nth 3..' ]]; then
# dotbare fgrep -- "./fgrep.bats" @test "fgrep edit lines"
echo "fgrep_words"
else
echo "$@"
fi

Loading…
Cancel
Save