feat: stop all and skip all with shared confirmation helper
This commit is contained in:
parent
4bc6666d0b
commit
6a3f354cb7
4 changed files with 179 additions and 54 deletions
|
|
@ -7,8 +7,8 @@ load test_helper
|
|||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "<time> <message...>" ]]
|
||||
[[ "${output}" =~ "every <rules> <time> <message...>" ]]
|
||||
[[ "${output}" =~ "stop <id|tag>" ]]
|
||||
[[ "${output}" =~ "skip <id|tag>" ]]
|
||||
[[ "${output}" =~ "stop <all|id|tag>" ]]
|
||||
[[ "${output}" =~ "skip <all|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|tag>" ]]
|
||||
[[ "${output}" =~ "stop <all|id|tag>" ]]
|
||||
}
|
||||
|
||||
@test "help skip shows skip usage" {
|
||||
run_nag help skip
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Usage:" ]]
|
||||
[[ "${output}" =~ "skip <id|tag>" ]]
|
||||
[[ "${output}" =~ "skip <all|id|tag>" ]]
|
||||
}
|
||||
|
||||
@test "help every shows every usage" {
|
||||
|
|
|
|||
|
|
@ -61,3 +61,29 @@ load test_helper
|
|||
run "${_NAG}" -f skip work
|
||||
[ "${status}" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "skip all reschedules repeating and deletes one-shots" {
|
||||
run_nag at "tomorrow 3pm" "one-shot"
|
||||
run_nag every day "tomorrow 3pm" "daily task"
|
||||
run "${_NAG}" -f skip all
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Stopped" ]]
|
||||
[[ "${output}" =~ "Skipped" ]]
|
||||
# One-shot removed, repeating kept.
|
||||
[ -s "${NAG_DIR}/alarms" ]
|
||||
! grep -q "one-shot" "${NAG_DIR}/alarms"
|
||||
grep -q "daily task" "${NAG_DIR}/alarms"
|
||||
}
|
||||
|
||||
@test "skip all requires -f" {
|
||||
run_nag at "tomorrow 3pm" "test"
|
||||
run "${_NAG}" skip all < /dev/null
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Skip" ]]
|
||||
[[ "${output}" =~ "-f" ]]
|
||||
}
|
||||
|
||||
@test "skip all with no alarms fails" {
|
||||
run "${_NAG}" -f skip all
|
||||
[ "${status}" -eq 1 ]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,3 +61,27 @@ load test_helper
|
|||
run "${_NAG}" -f stop work
|
||||
[ "${status}" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "stop all removes all alarms with confirmation" {
|
||||
run_nag at "tomorrow 3pm" "first"
|
||||
run_nag at "tomorrow 4pm" "second"
|
||||
run "${_NAG}" -f stop all
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Stopped" ]]
|
||||
run_nag
|
||||
[[ "${output}" =~ "Nothing to nag about" ]]
|
||||
}
|
||||
|
||||
@test "stop all requires -f" {
|
||||
run_nag at "tomorrow 3pm" "test"
|
||||
run "${_NAG}" stop all < /dev/null
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "Stop" ]]
|
||||
[[ "${output}" =~ "-f" ]]
|
||||
[ -s "${NAG_DIR}/alarms" ]
|
||||
}
|
||||
|
||||
@test "stop all with no alarms fails" {
|
||||
run "${_NAG}" -f stop all
|
||||
[ "${status}" -eq 1 ]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue