test(funtrack): imporve test coverage for funtrack

pull/13/head
kevin zhuang 4 years ago
parent 0690d5dc83
commit 2c485e1df1

@ -1,5 +1,9 @@
#!/usr/bin/env bats
setup() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
}
help() {
bash "${BATS_TEST_DIRNAME}"/../dotbare funtrack -h
}
@ -8,6 +12,18 @@ invalid_option() {
bash "${BATS_TEST_DIRNAME}"/../dotbare funtrack -p
}
untrack_file() {
bash "${BATS_TEST_DIRNAME}"/../dotbare funtrack --yes
}
temp_untrack() {
bash "${BATS_TEST_DIRNAME}"/../dotbare funtrack --yes -t
}
resume_track() {
bash "${BATS_TEST_DIRNAME}"/../dotbare funtrack --yes --resume
}
@test "funtrack help" {
run help
[ "${status}" -eq 0 ]
@ -19,3 +35,21 @@ invalid_option() {
[ "${status}" -eq 1 ]
[ "${lines[0]}" = "Invalid option: -p" ]
}
@test "funtrack untrack file" {
run untrack_file
[ "${status}" -eq 128 ]
[[ "${output}" =~ "fatal: pathspec '$HOME/selectgitfile' did not match any files" ]]
}
@test "funtrack temp untrack" {
run temp_untrack
[ "${status}" -eq 128 ]
[[ "${output}" =~ "fatal: Unable to mark file selectgitfile" ]]
}
@test "funtrack resume track" {
run resume_track
[ "${status}" -eq 128 ]
[[ "${output}" =~ "fatal: Unable to mark file selectgitfile" ]]
}

@ -32,12 +32,15 @@ elif [[ "$*" =~ '--header=select a commit' ]] && [[ "$*" =~ "show --color" ]]; t
elif [[ "$*" =~ "--no-multi --header=select a branch to checkout" ]]; then
# dotbare fcheckout --branch -- "./fcheckout.bats" @test "fcheckout branch"
echo "--branch"
elif [[ "$*" =~ '--header=select a file to checkout' ]] && [[ "$*" =~ "cat" ]]; then
elif [[ "$*" =~ '--header=select a file to checkout' ]] && [[ "$*" =~ "cat ${DOTBARE_TREE}/{}" ]]; then
# dotbare fcheckout --yes -s -- "./fcheckout.bats" @test "fcheckout select"
echo "selectgitfile"
elif [[ "$*" =~ '--header=select files to backup' ]] && [[ "$*" =~ "cat" ]]; then
elif [[ "$*" =~ '--header=select files to backup' ]] && [[ "$*" =~ "cat ${DOTBARE_TREE}/{}" ]]; then
# dotbare fbackup --select -- "./fbackup.bats" @test "fbackup select file"
echo "selectgitfile"
elif [[ "$*" =~ "--header=select files to untrack" ]] && [[ "$*" =~ "cat ${DOTBARE_TREE}/{}" ]]; then
# dotbare funtrack -- "./funtrack.bats" @test "funtrack untrack file"
echo "selectgitfile"
elif [[ "$*" =~ '--multi --preview ' ]] && [[ "$*" =~ "tree -L 1 -C --dirsfirst {}" ]]; then
# dotbare fadd --dir -- "./fadd.bats" @test "fadd stage selected dir"
echo "searchdir"

Loading…
Cancel
Save