From e0a22ccf4a98accf9f1feadac9e7ca20590df42c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 15 Sep 2014 08:54:44 -0700 Subject: [PATCH] Unit tests: add `nvm_has` --- test/fast/Unit tests/nvm_has | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 test/fast/Unit tests/nvm_has diff --git a/test/fast/Unit tests/nvm_has b/test/fast/Unit tests/nvm_has new file mode 100755 index 0000000..437d26f --- /dev/null +++ b/test/fast/Unit tests/nvm_has @@ -0,0 +1,12 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +nvm_has cat && type cat > /dev/null || die 'nvm_has locates "cat" properly' + +[ "~$(nvm_has foobarbaz 2>&1)" = "~" ] || die "nvm_has does not suppress error output" + +! nvm_has foobarbaz && ! type foobarbaz >/dev/null 2>&1 || die "nvm_has does not return a nonzero exit code when not found" +