feat: -f/-v/-e flags, 5-field TSV with tags in field 2
This commit is contained in:
parent
6b7fef5d2c
commit
2b36640567
9 changed files with 76 additions and 58 deletions
20
test/at.bats
20
test/at.bats
|
|
@ -8,10 +8,10 @@ load test_helper
|
|||
[[ "${output}" =~ "[1] Tomorrow, 3pm — take a break" ]]
|
||||
[ -f "${NAG_DIR}/alarms" ]
|
||||
[ "$(wc -l < "${NAG_DIR}/alarms")" -eq 1 ]
|
||||
# Verify TSV structure: id<TAB>timestamp<TAB><TAB>message
|
||||
# Verify TSV structure: id<TAB><empty-tags><TAB>timestamp<TAB><empty-rule><TAB>message
|
||||
local _line
|
||||
_line="$(cat "${NAG_DIR}/alarms")"
|
||||
[[ "${_line}" =~ ^1$'\t'[0-9]+$'\t'$'\t'take\ a\ break$ ]]
|
||||
[[ "${_line}" =~ ^1$'\t'$'\t'[0-9]+$'\t'$'\t'take\ a\ break$ ]]
|
||||
}
|
||||
|
||||
@test "at is the implicit subcommand" {
|
||||
|
|
@ -68,13 +68,27 @@ load test_helper
|
|||
run_nag at "${_last_month}" "annual thing"
|
||||
[ "${status}" -eq 0 ]
|
||||
local _ts
|
||||
_ts="$(cut -f2 "${NAG_DIR}/alarms")"
|
||||
_ts="$(cut -f3 "${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 "-f flag suppresses prompts" {
|
||||
run "${_NAG}" -f at "tomorrow 3pm" "flagged alarm"
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "flagged alarm" ]]
|
||||
}
|
||||
|
||||
@test "at creates alarm with 5-field TSV (empty tags)" {
|
||||
run_nag at "tomorrow 3pm" "tagged test"
|
||||
[ "${status}" -eq 0 ]
|
||||
local _line
|
||||
_line="$(cat "${NAG_DIR}/alarms")"
|
||||
[[ "${_line}" =~ ^1$'\t'$'\t'[0-9]+$'\t'$'\t'tagged\ test$ ]]
|
||||
}
|
||||
|
||||
@test "at without message fails" {
|
||||
run_nag at "tomorrow 3pm"
|
||||
[ "${status}" -eq 1 ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue