test: use regex match to avoid git wierd inconsistent "." at error

message
pull/13/head
kevin zhuang 4 years ago
parent e267f7b048
commit d13202f1a6

@ -48,17 +48,17 @@ stage_modified_file() {
@test "fadd stage selected file" {
run stage_selected_file
[ "${status}" -eq 128 ]
[ "${lines[0]}" = "fatal: pathspec 'searchfile' did not match any files" ]
[[ "${lines[0]}" =~ "fatal: pathspec 'searchfile' did not match any files" ]]
}
@test "fadd stage selected dir" {
run stage_selected_dir
[ "${status}" -eq 128 ]
[ "${lines[0]}" = "fatal: pathspec 'searchdir' did not match any files" ]
[[ "${lines[0]}" =~ "fatal: pathspec 'searchdir' did not match any files" ]]
}
@test "fadd stage modified file" {
run stage_modified_file
[ "${status}" -eq 128 ]
[ "${lines[0]}" = "fatal: pathspec '$HOME/modifiedfile' did not match any files" ]
[[ "${lines[0]}" =~ "fatal: pathspec '$HOME/modifiedfile' did not match any files" ]]
}

@ -42,27 +42,40 @@ checkout_selected_file() {
@test "fchekcout branch" {
run checkout_branch
result=$(echo "${lines[0]}" | tr '`' "'")
echo "${status}" >&3
echo "${output}" >&3
result=$(echo "${output}" | tr '`' "'")
[ "${status}" -eq 129 ]
[ "${result}" = "error: unknown option 'branch'" ]
[[ "${result}" =~ "error: unknown option 'branch'" ]]
}
@test "fchekcout commit" {
run checkout_commit
result=$(echo "${lines[0]}" | tr '`' "'")
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
[[ "${lines[0]}" =~ "fatal: your current branch 'master' does not have any commits yet" ]]
result=$(echo "${lines[1]}" | tr '`' "'")
else
result=$(echo "${lines[0]}" | tr '`' "'")
fi
[ "${status}" -eq 129 ]
[ "${result}" = "error: unknown option 'commitshow'" ]
[[ "${result}" =~ "error: unknown option 'commitshow'" ]]
}
@test "fcheckout modified" {
run checkout_modified_file
[ "${status}" -eq 1 ]
[ "${lines[0]}" = "error: pathspec '$HOME/modifiedfile' did not match any file(s) known to git" ]
[[ "${lines[0]}" =~ "error: pathspec '$HOME/modifiedfile' did not match any file(s) known to git" ]]
}
@test "fcheckout select" {
run checkout_selected_file
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
[[ "${lines[0]}" =~ "fatal: your current branch 'master' does not have any commits yet" ]]
[[ "${lines[1]}" =~ "error: pathspec 'commitdiff' did not match any file(s) known to git" ]]
[[ "${lines[2]}" =~ "error: pathspec '$HOME/selectgitfile' did not match any file(s) known to git" ]]
else
[[ "${lines[0]}" =~ "error: pathspec 'commitdiff' did not match any file(s) known to git" ]]
[[ "${lines[1]}" =~ "error: pathspec '$HOME/selectgitfile' did not match any file(s) known to git" ]]
fi
[ "${status}" -eq 1 ]
[ "${lines[0]}" = "error: pathspec 'commitdiff' did not match any file(s) known to git" ]
[ "${lines[1]}" = "error: pathspec '$HOME/selectgitfile' did not match any file(s) known to git" ]
}

@ -42,10 +42,10 @@ select_files() {
@test "freset select commit" {
run select_commit
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
[ "${lines[0]}" = "fatal: your current branch 'master' does not have any commits yet" ]
[[ "${lines[0]}" =~ "fatal: your current branch 'master' does not have any commits yet" ]]
else
result=$(echo "${lines[0]}" | tr '`' "'")
[ "${result}" = "error: unknown option 'commitshow'" ]
[[ "${result}" =~ "error: unknown option 'commitshow'" ]]
fi
[ "${status}" -eq 129 ]
}
@ -54,9 +54,9 @@ select_files() {
run select_files
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
[ "${status}" -eq 128 ]
[ "${lines[0]}" = "fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree." ]
[[ "${lines[0]}" =~ "fatal: ambiguous argument '$HOME/modifiedfile': unknown revision or path not in the working tree" ]]
else
[ "${status}" -eq 128 ]
[ "${lines[0]}" = "fatal: ambiguous argument '$HOME/modifiedfile': unknown revision or path not in the working tree." ]
[[ "${lines[0]}" =~ "fatal: ambiguous argument '$HOME/modifiedfile': unknown revision or path not in the working tree" ]]
fi
}

Loading…
Cancel
Save