2
0
mirror of https://github.com/kazhala/dotbare synced 2024-11-04 06:00:45 +00:00
dotbare/tests/fedit.bats

54 lines
1.0 KiB
Plaintext
Raw Normal View History

2020-05-13 01:35:35 +00:00
#!/usr/bin/env bats
help() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fedit -h
}
invalid_option() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fedit -p
}
no_file_selected() {
cd "${BATS_TEST_DIRNAME}"
bash "${BATS_TEST_DIRNAME}"/../dotbare fedit -m
}
2020-06-24 22:37:18 +00:00
edit_commits() {
2020-06-24 23:49:13 +00:00
export PATH="${BATS_TEST_DIRNAME}:$PATH"
2020-06-24 22:37:18 +00:00
bash "${BATS_TEST_DIRNAME}"/../dotbare fedit --commit
}
edit_files() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
2020-07-15 04:49:08 +00:00
export EDITOR="echo"
2020-06-24 22:37:18 +00:00
bash "${BATS_TEST_DIRNAME}"/../dotbare fedit
}
2020-05-13 01:35:35 +00:00
@test "fedit help" {
run help
[ "${status}" -eq 0 ]
2020-05-13 03:52:28 +00:00
[ "${lines[0]}" = "Usage: dotbare fedit [-h] [-m] [-c] ..." ]
2020-05-13 01:35:35 +00:00
}
@test "fedit invalid option" {
run invalid_option
[ "${status}" -eq 1 ]
2020-06-24 22:37:18 +00:00
[ "${lines[0]}" = "Invalid option: -p" ]
2020-05-13 01:35:35 +00:00
}
2020-05-13 03:41:58 +00:00
@test "fedit no file selected" {
2020-05-13 01:35:35 +00:00
run no_file_selected
[ "${status}" -eq 1 ]
}
2020-06-24 22:37:18 +00:00
@test "fedit edit commits" {
2020-06-24 23:49:13 +00:00
run edit_commits
2020-07-07 04:34:22 +00:00
[[ "${output}" =~ "rebase -i" ]]
[[ "${output}" =~ "fedit_commits" ]]
2020-06-24 22:37:18 +00:00
}
@test "fedit edit files" {
run edit_files
2020-07-15 04:49:08 +00:00
[[ "${output}" =~ "fedit_files" ]]
2020-06-24 22:37:18 +00:00
}