feat: tag support for skip/stop, requiring a force, similar to rm -f
This commit is contained in:
parent
f68a92323c
commit
8cf79c854b
5 changed files with 239 additions and 36 deletions
|
|
@ -7,8 +7,8 @@ load test_helper
|
|||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "<time> <message...>" ]]
|
||||
[[ "${output}" =~ "every <rules> <time> <message...>" ]]
|
||||
[[ "${output}" =~ "stop <id>" ]]
|
||||
[[ "${output}" =~ "skip <id>" ]]
|
||||
[[ "${output}" =~ "stop <id|tag>" ]]
|
||||
[[ "${output}" =~ "skip <id|tag>" ]]
|
||||
[[ "${output}" =~ "check" ]]
|
||||
[[ "${output}" =~ "help [<subcommand>]" ]]
|
||||
[[ "${output}" =~ "Options:" ]]
|
||||
|
|
@ -39,14 +39,14 @@ load test_helper
|
|||
run_nag help stop
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Usage:" ]]
|
||||
[[ "${output}" =~ "stop <id>" ]]
|
||||
[[ "${output}" =~ "stop <id|tag>" ]]
|
||||
}
|
||||
|
||||
@test "help skip shows skip usage" {
|
||||
run_nag help skip
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Usage:" ]]
|
||||
[[ "${output}" =~ "skip <id>" ]]
|
||||
[[ "${output}" =~ "skip <id|tag>" ]]
|
||||
}
|
||||
|
||||
@test "help every shows every usage" {
|
||||
|
|
|
|||
|
|
@ -32,3 +32,32 @@ load test_helper
|
|||
run_nag skip
|
||||
[ "${status}" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "skip by tag requires -f" {
|
||||
run_nag every day "tomorrow 3pm" "daily work"
|
||||
run_nag tag 1 work
|
||||
run "${_NAG}" skip work
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Would skip" ]]
|
||||
[[ "${output}" =~ "-f" ]]
|
||||
}
|
||||
|
||||
@test "skip by tag with -f reschedules matching alarms" {
|
||||
run_nag every day "tomorrow 3pm" "daily work"
|
||||
run_nag tag 1 work
|
||||
local _old_ts
|
||||
_old_ts="$(cut -f3 "${NAG_DIR}/alarms")"
|
||||
run "${_NAG}" -f skip work
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Skipped" ]]
|
||||
[[ "${output}" =~ "daily work" ]]
|
||||
local _new_ts
|
||||
_new_ts="$(cut -f3 "${NAG_DIR}/alarms")"
|
||||
(( _new_ts > _old_ts ))
|
||||
}
|
||||
|
||||
@test "skip by tag with no matches fails" {
|
||||
run_nag at "tomorrow 3pm" "test alarm"
|
||||
run "${_NAG}" -f skip work
|
||||
[ "${status}" -eq 1 ]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,3 +32,32 @@ load test_helper
|
|||
run_nag stop
|
||||
[ "${status}" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "stop by tag requires -f" {
|
||||
run_nag at "tomorrow 3pm" "tagged alarm"
|
||||
run_nag tag 1 work
|
||||
run "${_NAG}" stop work
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Would stop" ]]
|
||||
[[ "${output}" =~ "-f" ]]
|
||||
[ -s "${NAG_DIR}/alarms" ]
|
||||
}
|
||||
|
||||
@test "stop by tag with -f removes matching alarms" {
|
||||
run_nag at "tomorrow 3pm" "work alarm"
|
||||
run_nag tag 1 work
|
||||
run_nag at "tomorrow 4pm" "personal alarm"
|
||||
run "${_NAG}" -f stop work
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Stopped" ]]
|
||||
[[ "${output}" =~ "work alarm" ]]
|
||||
run_nag
|
||||
[[ "${output}" =~ "personal alarm" ]]
|
||||
[[ ! "${output}" =~ "work alarm" ]]
|
||||
}
|
||||
|
||||
@test "stop by tag with no matches fails" {
|
||||
run_nag at "tomorrow 3pm" "test alarm"
|
||||
run "${_NAG}" -f stop work
|
||||
[ "${status}" -eq 1 ]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue