mirror of
https://0xacab.org/liberate/backupninja.git
synced 2024-11-08 11:52:32 +01:00
tests: Improve test cases for sh handler
This commit is contained in:
parent
1aa55dc50d
commit
c3fcebbce5
24
test/sh.bats
24
test/sh.bats
@ -3,15 +3,27 @@ load common
|
||||
setup_sh() {
|
||||
cat << EOF > "${BATS_TMPDIR}/backup.d/test.sh"
|
||||
!#/bin/sh
|
||||
touch /var/backups/test_sh
|
||||
when = manual
|
||||
touch "${BN_BACKUPDIR}/testsh"
|
||||
EOF
|
||||
|
||||
chmod 0750 "${BATS_TMPDIR}/backup.d/test.sh"
|
||||
}
|
||||
|
||||
@test "sh: runs and creates file" {
|
||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.sh"
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f /var/backups/test_sh ]
|
||||
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log"
|
||||
teardown_sh() {
|
||||
cleanup_backups local
|
||||
}
|
||||
|
||||
@test "sh: runs and creates file" {
|
||||
runaction test.sh
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f "${BN_BACKUPDIR}/testsh" ]
|
||||
greplog "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
|
||||
}
|
||||
|
||||
@test "sh: is not executed in test mode" {
|
||||
testaction test.sh
|
||||
[ "$status" -eq 0 ]
|
||||
[ ! -f "${BN_BACKUPDIR}/testsh" ]
|
||||
greplog "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user