You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotbare/tests/finit.bats

62 lines
1.5 KiB
Plaintext

4 years ago
#!/usr/bin/env bats
setup() {
export DOTBARE_DIR="$HOME/.local/share/dotbare_test/.cfg"
export DOTBARE_TREE="$HOME/.local/share/dotbare_test"
}
teardown() {
if [[ "${DOTBARE_DIR}" == "$HOME/.local/share/dotbare_test/.cfg" ]] && \
[[ "${DOTBARE_TREE}" == "$HOME/.local/share/dotbare_test" ]]; then
4 years ago
rm -rf "${DOTBARE_TREE}"
fi
unset DOTBARE_DIR
unset DOTBARE_TREE
4 years ago
}
help() {
bash "${BATS_TEST_DIRNAME}"/../dotbare finit -h
}
init() {
bash "${BATS_TEST_DIRNAME}"/../dotbare finit --yes
4 years ago
}
migration() {
bash "${BATS_TEST_DIRNAME}"/../dotbare finit -u https://github.com/kazhala/dotfiles.git
}
submodule() {
bash "${BATS_TEST_DIRNAME}"/../dotbare finit -u https://github.com/kazhala/dotfiles.git -s --submodule
}
4 years ago
@test "finit help" {
run help
4 years ago
[ "${status}" -eq 0 ]
[ "${lines[0]}" = "Usage: dotbare finit [-h] [-y] [-s] [-u URL] ..." ]
4 years ago
}
4 years ago
@test "finit init dotbare" {
[[ -d "${DOTBARE_DIR}" ]] && rm -rf "${DOTBARE_DIR}"
4 years ago
run init
[ "${status}" -eq 0 ]
run init
[ "${status}" -eq 1 ]
[[ "${output}" =~ "${DOTBARE_DIR} already exist" ]]
4 years ago
}
4 years ago
@test "finit migration" {
4 years ago
[[ -d "${DOTBARE_DIR}" ]] && rm -rf "${DOTBARE_DIR}"
4 years ago
run migration
[ "${status}" -eq 0 ]
[[ "${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" ]]
4 years ago
}