Skip to content

Commit

Permalink
tests: plugins/cmd-returned-notify
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelicWizard committed Sep 9, 2021
1 parent 1c718d7 commit 569cfeb
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions test/plugins/cmd-returned-notify.plugin.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ load ../../plugins/available/cmd-returned-notify.plugin

@test "plugins cmd-returned-notify: notify after elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=0
export LAST_COMMAND_TIME=$(date +%s)
export COMMAND_DURATION_START_SECONDS="$SECONDS"
sleep 1
run precmd_return_notification
assert_success
Expand All @@ -18,31 +18,32 @@ load ../../plugins/available/cmd-returned-notify.plugin

@test "plugins cmd-returned-notify: do not notify before elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=10
export LAST_COMMAND_TIME=$(date +%s)
export COMMAND_DURATION_START_SECONDS="$SECONDS"
sleep 1
run precmd_return_notification
assert_success
assert_output $''
}

@test "plugins cmd-returned-notify: preexec no output" {
export LAST_COMMAND_TIME=
run preexec_return_notification
export COMMAND_DURATION_START_SECONDS=
run _command_duration_pre_exec
assert_success
assert_output ""
}

@test "plugins cmd-returned-notify: preexec no output env set" {
export LAST_COMMAND_TIME=$(date +%s)
run preexec_return_notification
skip "wut"
export COMMAND_DURATION_START_SECONDS="$SECONDS"
run _command_duration_pre_exec
assert_failure
assert_output ""
}

@test "plugins cmd-returned-notify: preexec set LAST_COMMAND_TIME" {
export LAST_COMMAND_TIME=
assert_equal "${LAST_COMMAND_TIME}" ""
NOW=$(date +%s)
preexec_return_notification
assert_equal "${LAST_COMMAND_TIME}" "${NOW}"
@test "plugins cmd-returned-notify: preexec set COMMAND_DURATION_START_SECONDS" {
export COMMAND_DURATION_START_SECONDS=
assert_equal "${COMMAND_DURATION_START_SECONDS}" ""
NOW="$SECONDS"
_command_duration_pre_exec
assert_equal "${COMMAND_DURATION_START_SECONDS}" "${NOW}"
}

0 comments on commit 569cfeb

Please sign in to comment.