Merge pull request #18 from MichaelAquilina/print_warning_missing_dep
Print warning if notify-send is a missing dependency
This commit is contained in:
commit
7f7027034c
2 changed files with 44 additions and 2 deletions
|
@ -122,4 +122,12 @@ function enable_auto_notify() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_auto_notify_reset_tracking
|
_auto_notify_reset_tracking
|
||||||
|
|
||||||
|
|
||||||
|
platform="$(uname)"
|
||||||
|
if [[ "$platform" == "Linux" ]] && ! type notify-send > /dev/null; then
|
||||||
|
printf "'notify-send' must be installed for zsh-auto-notify to work\n"
|
||||||
|
printf "Please install it with your relevant package manager\n"
|
||||||
|
else
|
||||||
enable_auto_notify
|
enable_auto_notify
|
||||||
|
fi
|
||||||
|
|
|
@ -1,23 +1,57 @@
|
||||||
#!/usr/bin/env zunit
|
#!/usr/bin/env zunit
|
||||||
|
|
||||||
@setup {
|
@setup {
|
||||||
load "../auto-notify.plugin.zsh"
|
function uname {
|
||||||
|
printf "Linux"
|
||||||
|
}
|
||||||
|
# Mock function for passing builds where we don't
|
||||||
|
# really need notify-send to be installed (e.g. Mac OSX)
|
||||||
|
function notify-send {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'version exported' {
|
@test 'version exported' {
|
||||||
git_version="$(git tag --list | sort -V | tail -1)"
|
git_version="$(git tag --list | sort -V | tail -1)"
|
||||||
git tag --list
|
git tag --list
|
||||||
|
|
||||||
|
load "../auto-notify.plugin.zsh"
|
||||||
|
|
||||||
assert "$AUTO_NOTIFY_VERSION" is_not_empty
|
assert "$AUTO_NOTIFY_VERSION" is_not_empty
|
||||||
assert "$AUTO_NOTIFY_VERSION" same_as "$git_version"
|
assert "$AUTO_NOTIFY_VERSION" same_as "$git_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test 'print warning if notify-send is not installed' {
|
||||||
|
function type {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
run load "../auto-notify.plugin.zsh"
|
||||||
|
|
||||||
|
assert "$lines[1]" same_as "'notify-send' must be installed for zsh-auto-notify to work"
|
||||||
|
assert "$lines[2]" same_as "Please install it with your relevant package manager"
|
||||||
|
|
||||||
|
@test 'dont load auto-notify if notify-send is not installed' {
|
||||||
|
function type {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
load "../auto-notify.plugin.zsh"
|
||||||
|
|
||||||
|
assert "_auto_notify_track" not_in $preexec_functions
|
||||||
|
assert "_auto_notify_send" not_in $precmd_functions
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@test 'hook functions are loaded by default' {
|
@test 'hook functions are loaded by default' {
|
||||||
|
load "../auto-notify.plugin.zsh"
|
||||||
|
|
||||||
assert '_auto_notify_track' in $preexec_functions
|
assert '_auto_notify_track' in $preexec_functions
|
||||||
assert '_auto_notify_send' in $precmd_functions
|
assert '_auto_notify_send' in $precmd_functions
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'enable/disable auto-notify' {
|
@test 'enable/disable auto-notify' {
|
||||||
|
load "../auto-notify.plugin.zsh"
|
||||||
|
|
||||||
disable_auto_notify
|
disable_auto_notify
|
||||||
assert '_auto_notify_track' not_in $preexec_functions
|
assert '_auto_notify_track' not_in $preexec_functions
|
||||||
assert '_auto_notify_send' not_in $precmd_functions
|
assert '_auto_notify_send' not_in $precmd_functions
|
||||||
|
|
Loading…
Add table
Reference in a new issue