test: splits monolith into a bats file for each subcommand

This commit is contained in:
Lewis Wynne 2026-04-02 11:39:48 +01:00
parent b6fde582bb
commit 2a3c9f264f
10 changed files with 535 additions and 458 deletions

34
test/skip.bats Normal file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env bats
load test_helper
@test "skip reschedules a repeating alarm" {
run_nag every day "tomorrow 3pm" daily task
run_nag skip 1
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Skipped" ]]
[ -s "${NAG_DIR}/alarms" ]
local _ts _now
_ts="$(cut -f2 "${NAG_DIR}/alarms")"
_now="$(date +%s)"
(( _ts > _now ))
}
@test "skip deletes a one-shot alarm" {
run_nag at "tomorrow 3pm" "one-shot"
run_nag skip 1
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Stopped" ]]
run_nag
[[ "${output}" =~ "Nothing to nag about" ]]
}
@test "skip with nonexistent ID fails" {
run_nag skip 99
[ "${status}" -eq 1 ]
}
@test "skip without ID fails" {
run_nag skip
[ "${status}" -eq 1 ]
}