Add `nvm_is_alias` unit tests.

Fixes 670.
master
Jordan Harband 2015-02-20 13:35:49 -08:00
parent e58d4abf11
commit 12ca8f2607
2 changed files with 22 additions and 1 deletions

3
nvm.sh
View File

@ -13,7 +13,8 @@ nvm_has() {
}
nvm_is_alias() {
command alias "$1" > /dev/null 2>&1
# this is intentionally not "command alias" so it works in zsh.
\alias "$1" > /dev/null 2>&1
}
nvm_get_latest() {

View File

@ -0,0 +1,20 @@
#!/bin/sh
cleanup () { unalias foo; unalias grep; }
die () { echo $@ ; cleanup ; exit 1; }
. ../../../nvm.sh
alias foo='bar'
nvm_is_alias foo || die '"nvm_is_alias foo" was not true'
! nvm_is_alias nvm_is_alias || die '"nvm_is_alias nvm_is_alias was not false'
alias grep='grep'
unalias grep || die '"unalias grep" failed'
! nvm_is_alias grep || die '"nvm_is_alias grep" with unaliased grep was not false'
alias grep='grep'
nvm_is_alias grep || die '"nvm_is_alias grep" with aliased grep was not true'
cleanup