2020-05-13 03:41:58 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
help() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare flog -h
|
|
|
|
}
|
|
|
|
|
|
|
|
invalid_option() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare flog -p
|
|
|
|
}
|
|
|
|
|
2020-06-25 02:41:25 +00:00
|
|
|
menu() {
|
|
|
|
export PATH="${BATS_TEST_DIRNAME}:$PATH"
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare flog
|
|
|
|
}
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
export PATH="${BATS_TEST_DIRNAME}:$PATH"
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare flog --reset -y
|
|
|
|
}
|
|
|
|
|
2020-05-13 03:41:58 +00:00
|
|
|
@test "flog help" {
|
|
|
|
run help
|
|
|
|
[ "${status}" -eq 0 ]
|
2020-06-25 02:41:25 +00:00
|
|
|
[ "${lines[0]}" = "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] [-y] ..." ]
|
2020-05-13 03:41:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "flog invalid option" {
|
|
|
|
run invalid_option
|
|
|
|
[ "${status}" -eq 1 ]
|
2020-06-25 02:41:25 +00:00
|
|
|
[ "${lines[0]}" = "Invalid option: -p" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "flog check routing" {
|
|
|
|
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
|
|
|
|
skip
|
|
|
|
fi
|
|
|
|
run menu
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "flog reset" {
|
|
|
|
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
|
|
|
|
skip
|
|
|
|
fi
|
|
|
|
run reset
|
|
|
|
[ "${status}" -eq 129 ]
|
|
|
|
result=$(echo "${lines[0]}" | tr '`' "'")
|
|
|
|
[[ "${result}" =~ "error: unknown option 'commitshow'" ]]
|
|
|
|
[[ "${output}" =~ "usage: git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]" ]]
|
2020-05-13 03:41:58 +00:00
|
|
|
}
|