You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotbare/tests/freset.bats

60 lines
1.3 KiB
Plaintext

4 years ago
#!/usr/bin/env bats
help() {
bash "${BATS_TEST_DIRNAME}"/../dotbare freset -h
}
invalid_option() {
bash "${BATS_TEST_DIRNAME}"/../dotbare freset -p
}
no_selection_made() {
bash "${BATS_TEST_DIRNAME}"/../dotbare freset
}
select_commit() {
4 years ago
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare freset --commit -y
}
select_files() {
4 years ago
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare freset
}
4 years ago
@test "freset help" {
run help
[ "${status}" -eq 0 ]
[ "${lines[0]}" = "Usage: dotbare freset [-h] [-c] [-S] [-H] [-y] ..." ]
4 years ago
}
@test "freset invalid option" {
run invalid_option
[ "${status}" -eq 1 ]
[ "${lines[0]}" = "Invalid option: -p" ]
}
@test "freset no selection made" {
run no_selection_made
[ "${status}" -eq 1 ]
}
@test "freset select commit" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
4 years ago
skip
fi
4 years ago
run select_commit
result=$(echo "${lines[0]}" | tr '`' "'")
[[ "${result}" =~ "error: unknown option 'commitshow'" ]]
[ "${status}" -eq 129 ]
}
@test "freset select files" {
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
4 years ago
skip
fi
4 years ago
run select_files
[ "${status}" -eq 128 ]
[[ "${lines[0]}" =~ "fatal: ambiguous argument '$HOME/modifiedfile': unknown revision or path not in the working tree" ]]
4 years ago
}