2
0
mirror of https://github.com/kazhala/dotbare synced 2024-11-17 21:25:32 +00:00
dotbare/tests/fadd.bats

61 lines
1.3 KiB
Plaintext
Raw Normal View History

2020-05-13 00:39:10 +00:00
#!/usr/bin/env bats
help() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fadd -h
}
invalid_option() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fadd -p
}
no_file_selected() {
cd "${BATS_TEST_DIRNAME}"
bash "${BATS_TEST_DIRNAME}"/../dotbare fadd -d
}
stage_selected_file() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare fadd -f
}
stage_selected_dir() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare fadd --dir
}
stage_modified_file() {
export PATH="${BATS_TEST_DIRNAME}:$PATH"
bash "${BATS_TEST_DIRNAME}"/../dotbare fadd --dir
}
2020-05-13 00:39:10 +00:00
@test "fadd help" {
run help
[ "${status}" -eq 0 ]
[ "${lines[0]}" = "Usage: dotbare fadd [-h] [-f] [-d] ..." ]
}
2020-05-13 01:32:18 +00:00
@test "fadd invalid option" {
2020-05-13 00:39:10 +00:00
run invalid_option
[ "${status}" -eq 1 ]
[ "${lines[0]}" = "Invalid option: -p" ]
2020-05-13 00:39:10 +00:00
}
@test "fadd no file selected" {
run no_file_selected
[ "${status}" -eq 1 ]
}
@test "fadd stage selected file" {
run stage_selected_file
[ "${status}" -eq 129 ]
result=$(echo "${lines[0]}" | tr '`' "'")
[ "${result}" = "error: unknown option 'multi --preview head -200 {}'" ]
}
@test "fadd stage selected dir" {
run stage_selected_dir
[ "${status}" -eq 129 ]
result=$(echo "${lines[0]}" | tr '`' "'")
[ "${result}" = "error: unknown option 'multi --preview tree -L 1 -C --dirsfirst {}'" ]
}