2
0
mirror of https://github.com/kazhala/dotbare synced 2024-11-04 06:00:45 +00:00
dotbare/tests/fcheckout.bats
kevin zhuang 542bc0838c docs(changlog): update new changes
fix: test

..

test: improve wording and variable names in test

..

..
2020-06-28 14:16:24 +10:00

79 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bats
setup() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
}
help() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fcheckout -h
}
invalid_option() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fcheckout -p
}
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
}
@test "fcheckout help" {
run help
[ "${status}" -eq 0 ]
[ "${lines[0]}" = "Usage: dotbare fcheckout [-h] [-s] [-b] [-c] [-y] ..." ]
}
@test "fcheckout invalid option" {
run invalid_option
[ "${status}" -eq 1 ]
[ "${lines[0]}" = "Invalid option: -p" ]
}
@test "fcheckout branch" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
skip
fi
run checkout_branch
[ "${status}" -eq 129 ]
[[ "${output}" =~ "fcheckout_branch" ]]
}
@test "fcheckout commit" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
skip
fi
run checkout_commit
[ "${status}" -eq 129 ]
[[ "${output}" =~ "fcheckout_commit" ]]
}
@test "fcheckout modified" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
skip
fi
run checkout_modified_file
[ "${status}" -eq 1 ]
[[ "${output}" =~ "fcheckout_modified" ]]
}
@test "fcheckout select" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
skip
fi
run checkout_selected_file
[[ "${lines[0]}" =~ "fcheckout_select_commitdiff" ]]
[[ "${lines[1]}" =~ "fcheckout_select_gitfile" ]]
[ "${status}" -eq 1 ]
}