fix: dates in the past just roll forwards to _next_occurence

This commit is contained in:
Lewis Wynne 2026-04-02 01:13:39 +01:00
parent 94ae235815
commit 464362bcbf
2 changed files with 53 additions and 17 deletions

View file

@ -71,11 +71,29 @@ load test_helper
[ "${status}" -eq 1 ]
}
@test "at with explicit past date fails" {
@test "at rejects yesterday" {
run_nag at "yesterday 3pm" "too late"
[ "${status}" -eq 1 ]
}
@test "at rejects ago" {
run_nag at "2 hours ago" "too late"
[ "${status}" -eq 1 ]
}
@test "at rolls past date forward to next year" {
local _last_month
_last_month="$(date -d "last month" "+%B %-d")"
run_nag at "${_last_month}" "annual thing"
[ "${status}" -eq 0 ]
local _ts
_ts="$(cut -f2 "${NAG_DIR}/alarms")"
local _ts_year _next_year
_ts_year="$(date -d "@${_ts}" +%Y)"
_next_year="$(date -d "+1 year" +%Y)"
[ "${_ts_year}" = "${_next_year}" ]
}
@test "at without message fails" {
run_nag at "tomorrow 3pm"
[ "${status}" -eq 1 ]