2020-05-13 03:41:58 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
help() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare freset -h
|
|
|
|
}
|
|
|
|
|
|
|
|
invalid_option() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare freset -p
|
|
|
|
}
|
|
|
|
|
2020-06-22 01:19:27 +00:00
|
|
|
no_selection_made() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare freset
|
|
|
|
}
|
|
|
|
|
|
|
|
select_commit() {
|
|
|
|
export PATH="${BATS_TEST_DIRNAME}:$PATH"
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare freset --commit -y
|
|
|
|
}
|
|
|
|
|
|
|
|
select_files() {
|
|
|
|
export PATH="${BATS_TEST_DIRNAME}:$PATH"
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare freset
|
|
|
|
}
|
|
|
|
|
2020-05-13 03:41:58 +00:00
|
|
|
@test "freset help" {
|
|
|
|
run help
|
|
|
|
[ "${status}" -eq 0 ]
|
2020-06-22 01:19:27 +00:00
|
|
|
[ "${lines[0]}" = "Usage: dotbare freset [-h] [-c] [-S] [-H] [-y] ..." ]
|
2020-05-13 03:41:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "freset invalid option" {
|
|
|
|
run invalid_option
|
|
|
|
[ "${status}" -eq 1 ]
|
2020-06-22 01:19:27 +00:00
|
|
|
[ "${lines[0]}" = "Invalid option: -p" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "freset select commit" {
|
|
|
|
run select_commit
|
2020-06-22 02:25:17 +00:00
|
|
|
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
|
|
|
|
[ "${lines[0]}" = "fatal: your current branch 'master' does not have any commits yet" ]
|
|
|
|
else
|
|
|
|
result=$(echo "${lines[0]}" | tr '`' "'")
|
|
|
|
[ "${result}" = "error: unknown option 'no-multi'" ]
|
|
|
|
fi
|
2020-06-22 01:19:27 +00:00
|
|
|
[ "${status}" -eq 129 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "freset no selection made" {
|
|
|
|
run no_selection_made
|
|
|
|
[ "${status}" -eq 1 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "freset select files" {
|
|
|
|
run select_files
|
2020-06-22 02:25:17 +00:00
|
|
|
if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then
|
|
|
|
[ "${status}" -eq 128 ]
|
|
|
|
[ "${lines[0]}" = "fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree." ]
|
|
|
|
else
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
[ -z "${output}" ]
|
|
|
|
fi
|
2020-05-13 03:41:58 +00:00
|
|
|
}
|