2020-05-13 02:02:58 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
export DOTBARE_DIR="$HOME/.local/share/dotbare_test/.cfg"
|
|
|
|
export DOTBARE_TREE="$HOME/.local/share/dotbare_test"
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
2020-06-25 02:03:17 +00:00
|
|
|
if [[ "${DOTBARE_DIR}" == "$HOME/.local/share/dotbare_test/.cfg" ]] && \
|
|
|
|
[[ "${DOTBARE_TREE}" == "$HOME/.local/share/dotbare_test" ]]; then
|
2020-05-13 02:19:38 +00:00
|
|
|
rm -rf "${DOTBARE_TREE}"
|
|
|
|
fi
|
2020-05-13 03:23:36 +00:00
|
|
|
unset DOTBARE_DIR
|
|
|
|
unset DOTBARE_TREE
|
2020-05-13 02:02:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
help() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare finit -h
|
|
|
|
}
|
|
|
|
|
|
|
|
init() {
|
2020-06-25 02:03:17 +00:00
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare finit --yes
|
2020-05-13 02:02:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
migration() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare finit -u https://github.com/kazhala/dotfiles.git
|
|
|
|
}
|
|
|
|
|
2020-06-25 02:03:17 +00:00
|
|
|
submodule() {
|
|
|
|
bash "${BATS_TEST_DIRNAME}"/../dotbare finit -u https://github.com/kazhala/dotfiles.git -s --submodule
|
|
|
|
}
|
|
|
|
|
2020-05-13 02:02:58 +00:00
|
|
|
@test "finit help" {
|
|
|
|
run help
|
2020-05-13 05:08:08 +00:00
|
|
|
[ "${status}" -eq 0 ]
|
2020-06-18 05:11:38 +00:00
|
|
|
[ "${lines[0]}" = "Usage: dotbare finit [-h] [-y] [-s] [-u URL] ..." ]
|
2020-05-13 02:02:58 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 03:41:58 +00:00
|
|
|
@test "finit init dotbare" {
|
2020-06-25 02:03:17 +00:00
|
|
|
[[ -d "${DOTBARE_DIR}" ]] && rm -rf "${DOTBARE_DIR}"
|
2020-05-13 02:02:58 +00:00
|
|
|
run init
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
run init
|
|
|
|
[ "${status}" -eq 1 ]
|
2020-06-25 02:03:17 +00:00
|
|
|
[[ "${output}" =~ "${DOTBARE_DIR} already exist" ]]
|
2020-05-13 02:02:58 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 03:41:58 +00:00
|
|
|
@test "finit migration" {
|
2020-05-13 02:19:38 +00:00
|
|
|
[[ -d "${DOTBARE_DIR}" ]] && rm -rf "${DOTBARE_DIR}"
|
2020-05-13 02:02:58 +00:00
|
|
|
run migration
|
|
|
|
[ "${status}" -eq 0 ]
|
2020-06-25 02:03:17 +00:00
|
|
|
[[ "${output}" =~ "Migration completed" ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "finit submodule" {
|
|
|
|
[[ -d "${DOTBARE_DIR}" ]] && rm -rf "${DOTBARE_DIR}"
|
|
|
|
run submodule
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
result=$(echo "${output}" | tr "\n" " ")
|
|
|
|
[[ "${result}" =~ "Cloning submodules ... Migration completed" ]]
|
2020-05-13 02:02:58 +00:00
|
|
|
}
|