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/fbackup.bats

61 lines
1.0 KiB
Plaintext

4 years ago
#!/usr/bin/env bats
setup() {
export DOTBARE_BACKUP="$HOME/.local/share/dotbare_test"
export DOTBARE_DIR="${HOME}/.cfg/"
4 years ago
}
teardown() {
rm -r "$DOTBARE_BACKUP"
unset DOTBARE_BACKUP
}
help() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fbackup -h
}
invalid_option() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fbackup -f
}
backup() {
bash "${BATS_TEST_DIRNAME}"/../dotbare fbackup
}
individual_backup() {
cd "${BATS_TEST_DIRNAME}"
bash "${BATS_TEST_DIRNAME}"/../dotbare fbackup -p fadd.bats
}
check_empty() {
git log
}
4 years ago
@test "fbackup help" {
run help
[ "${status}" -eq 0 ]
}
@test "fbackup invalid option" {
run invalid_option
[ "${status}" -eq 1 ]
[ "${lines[0]}" = 'Invalid option: f' ]
}
4 years ago
@test "fbackup backup all files" {
run check_empty
if [ "${status}" -eq 0 ]; then
run backup
[ "${status}" -eq 0 ]
[ -f "${DOTBARE_BACKUP}"/.bashrc ]
else
skip
fi
4 years ago
}
4 years ago
@test "fbackup backup individual file" {
4 years ago
run individual_backup
[ "${status}" -eq 0 ]
[ -f "${DOTBARE_BACKUP}"/fadd.bats ]
4 years ago
}