Add support for custom message formats
This commit is contained in:
parent
eaf5936f1e
commit
aed7176e73
4 changed files with 77 additions and 5 deletions
26
tests/test_auto_notify_format.zunit
Normal file
26
tests/test_auto_notify_format.zunit
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env zunit
|
||||
|
||||
@setup {
|
||||
load "../auto-notify.plugin.zsh"
|
||||
}
|
||||
|
||||
@test 'auto-notify-format no parameters' {
|
||||
run _auto_notify_format "Hello World" "foo" "bar" "baz"
|
||||
|
||||
assert $state equals 0
|
||||
assert "$output" same_as "Hello World"
|
||||
}
|
||||
|
||||
@test 'auto-notify-format correct formatting 1' {
|
||||
run _auto_notify_format "Command run is - %command (%elapsed seconds)" "zypper up" "10" "0"
|
||||
|
||||
assert $state equals 0
|
||||
assert "$output" same_as "Command run is - zypper up (10 seconds)"
|
||||
}
|
||||
|
||||
@test 'auto-notify-format correct formatting 2' {
|
||||
run _auto_notify_format "Exit code is %exit_code!" "zypper up" "10" "-101"
|
||||
|
||||
assert $state equals 0
|
||||
assert "$output" same_as "Exit code is -101!"
|
||||
}
|
|
@ -126,3 +126,17 @@
|
|||
assert "$lines[1]" same_as "Unknown platform for sending notifications: Hal9000"
|
||||
assert "$lines[2]" same_as "Please post an issue on gitub.com/MichaelAquilina/zsh-auto-notify/issues/"
|
||||
}
|
||||
|
||||
@test 'auto-notify-send sends custom message' {
|
||||
AUTO_COMMAND="doom -i"
|
||||
AUTO_COMMAND_FULL="doom -i"
|
||||
AUTO_COMMAND_START=11055
|
||||
AUTO_NOTIFY_TITLE="%command has completed in %elapseds yo"
|
||||
AUTO_NOTIFY_BODY="%command exited with code %exit_code"
|
||||
|
||||
run _auto_notify_send
|
||||
|
||||
assert $state equals 0
|
||||
assert "$lines[1]" same_as 'Notification Title: doom -i has completed in 45s yo'
|
||||
assert "$lines[2]" same_as "Notification Body: doom -i exited with code 0"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue