2
0
mirror of https://github.com/kazhala/dotbare synced 2024-11-04 06:00:45 +00:00
dotbare/tests/flog.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

50 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bats
help() {
bash "${BATS_TEST_DIRNAME}"/../dotbare flog -h
}
invalid_option() {
bash "${BATS_TEST_DIRNAME}"/../dotbare flog -p
}
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
}
@test "flog help" {
run help
[ "${status}" -eq 0 ]
[ "${lines[0]}" = "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] [-y] ..." ]
}
@test "flog invalid option" {
run invalid_option
[ "${status}" -eq 1 ]
[ "${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 ]
[[ "${output}" =~ "usage: git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]" ]]
[[ "${output}" =~ "flog_reset" ]]
}