2020-05-13 01:32:18 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
2020-06-23 07:05:50 +00:00
|
|
|
setup() {
|
|
|
|
export PATH="${BATS_TEST_DIRNAME}:$PATH"
|
|
|
|
}
|
|
|
|
|
2020-05-13 01:32:18 +00:00
|
|
|
help() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare fcheckout -h
|
|
|
|
}
|
|
|
|
|
|
|
|
invalid_option() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare fcheckout -p
|
|
|
|
}
|
|
|
|
|
2020-06-23 07:05:50 +00:00
|
|
|
checkout_branch() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare fcheckout --branch
|
|
|
|
}
|
|
|
|
|
|
|
|
checkout_commit() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare fcheckout -c
|
|
|
|
}
|
|
|
|
|
|
|
|
checkout_modified_file() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare fcheckout -y
|
|
|
|
}
|
|
|
|
|
|
|
|
checkout_selected_file() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare fcheckout --yes -s
|
|
|
|
}
|
|
|
|
|
2020-05-13 01:32:18 +00:00
|
|
|
@test "fcheckout help" {
|
|
|
|
run help
|
|
|
|
[ "${status}" -eq 0 ]
|
2020-06-23 07:05:50 +00:00
|
|
|
[ "${lines[0]}" = "Usage: dotbare fcheckout [-h] [-s] [-b] [-c] ..." ]
|
2020-05-13 01:32:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "fchekcout invalid option" {
|
|
|
|
run invalid_option
|
|
|
|
[ "${status}" -eq 1 ]
|
2020-06-23 07:05:50 +00:00
|
|
|
[ "${lines[0]}" = "Invalid option: -p" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "fchekcout branch" {
|
|
|
|
run checkout_branch
|
|
|
|
result=$(echo "${lines[0]}" | tr '`' "'")
|
|
|
|
[ "${status}" -eq 129 ]
|
|
|
|
[ "${result}" = "error: unknown option 'branch'" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "fchekcout commit" {
|
|
|
|
run checkout_commit
|
|
|
|
result=$(echo "${lines[0]}" | tr '`' "'")
|
|
|
|
[ "${status}" -eq 129 ]
|
|
|
|
[ "${result}" = "error: unknown option 'commitshow'" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "fcheckout modified" {
|
|
|
|
run checkout_modified_file
|
|
|
|
[ "${status}" -eq 1 ]
|
|
|
|
[ "${lines[0]}" = "error: pathspec '/Users/kevinzhuang/modifiedfile' did not match any file(s) known to git" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "fcheckout select" {
|
|
|
|
run checkout_selected_file
|
|
|
|
[ "${status}" -eq 1 ]
|
|
|
|
[ "${lines[0]}" = "error: pathspec 'commitdiff' did not match any file(s) known to git" ]
|
|
|
|
[ "${lines[1]}" = "error: pathspec '/Users/kevinzhuang/selectgitfile' did not match any file(s) known to git" ]
|
2020-05-13 01:32:18 +00:00
|
|
|
}
|