2014-09-29 09:02:33 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
die () { echo $@ ; cleanup ; exit 1; }
|
|
|
|
|
|
|
|
cleanup() {
|
2015-01-13 18:22:22 +08:00
|
|
|
unset -f nvm_ls_remote nvm_ls_remote_iojs
|
2014-09-29 09:02:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
. ../../../nvm.sh
|
|
|
|
|
|
|
|
nvm_ls_remote() {
|
|
|
|
echo "N/A"
|
|
|
|
}
|
|
|
|
OUTPUT="$(nvm_remote_version foo)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
|
2015-01-13 18:22:22 +08:00
|
|
|
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
|
|
|
|
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
|
2014-09-29 09:02:33 +08:00
|
|
|
|
2015-01-13 18:22:22 +08:00
|
|
|
nvm_ls_remote_iojs() {
|
|
|
|
echo "N/A"
|
|
|
|
}
|
|
|
|
OUTPUT="$(nvm_remote_version iojs-foo)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
|
2014-09-29 09:02:33 +08:00
|
|
|
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"
|
|
|
|
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"
|
|
|
|
|
2015-01-13 18:22:22 +08:00
|
|
|
|
2014-09-29 09:02:33 +08:00
|
|
|
nvm_ls_remote() {
|
|
|
|
echo "test output"
|
|
|
|
echo "more test output"
|
|
|
|
echo "pattern received: _$1_"
|
|
|
|
}
|
|
|
|
OUTPUT="$(nvm_remote_version foo)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
|
|
|
|
[ "_$OUTPUT" = "_pattern received: _foo_" ] \
|
|
|
|
|| die "nvm_remote_version foo did not return last line only of nvm_ls_remote foo; got $OUTPUT"
|
|
|
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version foo did not exit with 0, got $EXIT_CODE"
|
|
|
|
|
2015-01-13 18:22:22 +08:00
|
|
|
nvm_ls_remote_iojs() {
|
|
|
|
echo "test iojs output"
|
|
|
|
echo "more iojs test output"
|
|
|
|
echo "iojs pattern received: _$1_"
|
|
|
|
|
|
|
|
}
|
|
|
|
OUTPUT="$(nvm_remote_version iojs-foo)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
|
|
|
|
[ "_$OUTPUT" = "_iojs pattern received: _iojs-foo_" ] \
|
|
|
|
|| die "nvm_remote_version iojs-foo did not return last line only of nvm_ls_remote_iojs foo; got $OUTPUT"
|
|
|
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs-foo did not exit with 0, got $EXIT_CODE"
|
|
|
|
|
2014-09-29 09:02:33 +08:00
|
|
|
cleanup
|
|
|
|
|