2020-05-13 00:39:10 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
help() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare -h
|
|
|
|
}
|
|
|
|
|
|
|
|
addall() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare add --all
|
|
|
|
}
|
|
|
|
|
|
|
|
routing() {
|
|
|
|
"${BATS_TEST_DIRNAME}"/../dotbare fadd -h
|
|
|
|
}
|
|
|
|
|
2020-06-21 22:14:23 +00:00
|
|
|
routing2() {
|
|
|
|
"${BATS_TEST_DIRNAME}"/../dotbare flog -h
|
|
|
|
}
|
|
|
|
|
2020-05-13 00:39:10 +00:00
|
|
|
normal_git() {
|
2020-07-07 01:20:22 +00:00
|
|
|
export PATH="${BATS_TEST_DIRNAME}:$PATH"
|
2020-05-13 11:04:02 +00:00
|
|
|
"${BATS_TEST_DIRNAME}"/../dotbare add -h
|
2020-05-13 00:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
invalid_command() {
|
|
|
|
"${BATS_TEST_DIRNAME}"/../dotbare hello
|
|
|
|
}
|
|
|
|
|
2020-06-27 23:28:09 +00:00
|
|
|
version() {
|
|
|
|
"${BATS_TEST_DIRNAME}"/../dotbare --version
|
|
|
|
}
|
|
|
|
|
2020-07-07 01:20:22 +00:00
|
|
|
no_argument() {
|
|
|
|
export PATH="${BATS_TEST_DIRNAME}:$PATH"
|
|
|
|
"${BATS_TEST_DIRNAME}"/../dotbare
|
|
|
|
}
|
|
|
|
|
2020-05-13 03:41:58 +00:00
|
|
|
@test "main help" {
|
2020-05-13 00:39:10 +00:00
|
|
|
run help
|
|
|
|
[ "${status}" -eq 0 ]
|
2020-06-27 23:28:09 +00:00
|
|
|
[ "${lines[0]}" = "Usage: dotbare [-h] [-v] [COMMANDS] [OPTIONS] ..." ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "main version" {
|
|
|
|
run version
|
|
|
|
[ "${status}" -eq 0 ]
|
2020-06-28 00:38:55 +00:00
|
|
|
[[ "${output}" =~ "Current dotbare version: ${DOTBARE_VERSION}" ]]
|
2020-05-13 00:39:10 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 03:41:58 +00:00
|
|
|
@test "main disable add --all" {
|
2020-05-13 00:39:10 +00:00
|
|
|
run addall
|
|
|
|
[ "${status}" -eq 1 ]
|
|
|
|
[ "${lines[0]}" = "If you intend to stage all modified file, run dotbare add -u" ]
|
|
|
|
}
|
|
|
|
|
2020-05-13 03:41:58 +00:00
|
|
|
@test "main routing" {
|
2020-05-13 00:39:10 +00:00
|
|
|
run routing
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
[ "${lines[0]}" = "Usage: dotbare fadd [-h] [-f] [-d] ..." ]
|
|
|
|
}
|
|
|
|
|
2020-06-22 02:25:17 +00:00
|
|
|
@test "main routing2" {
|
2020-06-21 22:14:23 +00:00
|
|
|
run routing2
|
|
|
|
[ "${status}" -eq 0 ]
|
2020-06-25 04:34:51 +00:00
|
|
|
[ "${lines[0]}" = "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] [-y] ..." ]
|
2020-06-21 22:14:23 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 03:41:58 +00:00
|
|
|
@test "main git command" {
|
2020-05-13 00:39:10 +00:00
|
|
|
run normal_git
|
2020-07-07 01:20:22 +00:00
|
|
|
[ "${status}" -eq 0 ]
|
2020-07-07 05:20:31 +00:00
|
|
|
[[ "${output}" =~ "add -h" ]]
|
2020-05-13 00:39:10 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 03:41:58 +00:00
|
|
|
@test "main invliad command" {
|
2020-05-13 00:39:10 +00:00
|
|
|
run invalid_command
|
|
|
|
[ "${status}" -eq 1 ]
|
|
|
|
}
|
2020-07-07 01:20:22 +00:00
|
|
|
|
|
|
|
@test "main no argument" {
|
|
|
|
run no_argument
|
|
|
|
[[ "${output}" =~ "Available commands" ]]
|
|
|
|
}
|