feat: unsnooze command for resuming snoozed alarms

This commit is contained in:
Lewis Wynne 2026-04-02 19:05:07 +01:00
parent ad68c225d5
commit ed10ae8842
2 changed files with 213 additions and 0 deletions

View file

@ -91,3 +91,64 @@ load test_helper
_line="$(cat "${NAG_DIR}/snoozed")"
[[ "${_line}" == work$'\t'* ]]
}
@test "unsnooze by ID removes entry from snoozed file" {
run_nag at "tomorrow 3pm" "take a break"
run_nag snooze 1
run_nag unsnooze 1
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Unsnoozed [1]" ]]
! grep -q "^1" "${NAG_DIR}/snoozed" 2>/dev/null
}
@test "unsnooze all removes snoozed file" {
run_nag snooze all
run_nag unsnooze all
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Unsnoozed all" ]]
[ ! -f "${NAG_DIR}/snoozed" ]
}
@test "unsnooze all when nothing snoozed says so" {
run_nag unsnooze all
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Nothing is snoozed" ]]
}
@test "unsnooze with no args fails" {
run_nag unsnooze
[ "${status}" -eq 1 ]
}
@test "unsnooze by tag removes tag entry" {
run_nag at "tomorrow 3pm" "work task"
run_nag tag 1 work
run_nag snooze work
run_nag unsnooze work
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Unsnoozed [work]" ]]
! grep -q "^work" "${NAG_DIR}/snoozed" 2>/dev/null
}
@test "unsnooze by tag requires -f" {
run_nag at "tomorrow 3pm" "work task"
run_nag tag 1 work
run_nag snooze work
run "${_NAG}" unsnooze work < /dev/null
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Unsnooze" ]]
[[ "${output}" =~ "-f" ]]
}
@test "unsnooze nonexistent ID fails" {
run_nag unsnooze 99
[ "${status}" -eq 1 ]
}
@test "unsnooze tag that is not snoozed fails" {
run_nag at "tomorrow 3pm" "work task"
run_nag tag 1 work
run "${_NAG}" -f unsnooze work
[ "${status}" -eq 1 ]
[[ "${output}" =~ "not snoozed" ]]
}