fix: cleans up expired and orphaned metadata on alarm removal

This commit is contained in:
Lewis Wynne 2026-04-02 20:36:42 +01:00
parent 6a588aaa9c
commit 5d48fb9c9c
4 changed files with 95 additions and 4 deletions

View file

@ -85,3 +85,36 @@ load test_helper
run "${_NAG}" -f stop all
[ "${status}" -eq 1 ]
}
@test "stop by ID cleans up snoozed metadata" {
run_nag at "tomorrow 3pm" "take a break"
run_nag snooze 1
[ -f "${NAG_DIR}/snoozed" ]
run_nag stop 1
[ "${status}" -eq 0 ]
if [ -f "${NAG_DIR}/snoozed" ]; then
! grep -q "^1" "${NAG_DIR}/snoozed"
fi
}
@test "stop by tag cleans up snoozed metadata" {
run_nag at "tomorrow 3pm" "work task"
run_nag tag 1 work
run_nag snooze 1
[ -f "${NAG_DIR}/snoozed" ]
run "${_NAG}" -f stop work
[ "${status}" -eq 0 ]
if [ -f "${NAG_DIR}/snoozed" ]; then
! grep -q "^1" "${NAG_DIR}/snoozed"
fi
}
@test "stop all cleans up snoozed metadata" {
run_nag at "tomorrow 3pm" "first"
run_nag at "tomorrow 4pm" "second"
run_nag snooze all
[ -f "${NAG_DIR}/snoozed" ]
run "${_NAG}" -f stop all
[ "${status}" -eq 0 ]
[ ! -f "${NAG_DIR}/snoozed" ] || [ ! -s "${NAG_DIR}/snoozed" ]
}