fix: cleans up expired and orphaned metadata on alarm removal
This commit is contained in:
parent
6a588aaa9c
commit
5d48fb9c9c
4 changed files with 95 additions and 4 deletions
|
|
@ -197,3 +197,19 @@ SCRIPT
|
|||
[ "${status}" -eq 0 ]
|
||||
grep -q "expired snooze" "${_fired}"
|
||||
}
|
||||
|
||||
@test "check sweeps orphaned snooze entries for removed alarms" {
|
||||
local _future_ts=$(( $(date +%s) + 3600 ))
|
||||
write_alarm "$(printf "2\t\t%s\t\treal alarm" "${_future_ts}")"
|
||||
# ID 1 does not exist in alarms, ID 2 does.
|
||||
printf "1\\n" > "${NAG_DIR}/snoozed"
|
||||
printf "2\\n" >> "${NAG_DIR}/snoozed"
|
||||
|
||||
run_nag check
|
||||
[ "${status}" -eq 0 ]
|
||||
|
||||
# Orphan ID 1 should be swept, ID 2 should remain.
|
||||
[ -f "${NAG_DIR}/snoozed" ]
|
||||
! grep -q "^1$" "${NAG_DIR}/snoozed"
|
||||
grep -q "^2$" "${NAG_DIR}/snoozed"
|
||||
}
|
||||
|
|
@ -87,3 +87,15 @@ load test_helper
|
|||
run "${_NAG}" -f skip all
|
||||
[ "${status}" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "skip one-shot cleans up snoozed metadata" {
|
||||
run_nag at "tomorrow 3pm" "one-shot"
|
||||
run_nag snooze 1
|
||||
[ -f "${NAG_DIR}/snoozed" ]
|
||||
run_nag skip 1
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Stopped" ]]
|
||||
if [ -f "${NAG_DIR}/snoozed" ]; then
|
||||
! grep -q "^1" "${NAG_DIR}/snoozed"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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" ]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue