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() {
|
2016-04-25 07:26:32 +08:00
|
|
|
if [ -z "$1" ] || ! nvm_is_iojs_version "$1"; then
|
|
|
|
echo "test_output"
|
|
|
|
echo "more_test_output"
|
|
|
|
echo "pattern_received:_$1_"
|
2015-01-24 02:59:49 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
nvm_ls_remote_iojs() {
|
2015-02-11 06:41:45 +08:00
|
|
|
if [ -z "$1" ] || nvm_is_iojs_version "$1"; then
|
2016-04-25 07:26:32 +08:00
|
|
|
echo "test_iojs_output"
|
|
|
|
echo "more_iojs_test_output"
|
|
|
|
echo "iojs_pattern_received:_$1_"
|
2015-01-24 02:59:49 +08:00
|
|
|
fi
|
2014-09-29 09:02:33 +08:00
|
|
|
}
|
|
|
|
OUTPUT="$(nvm_remote_version foo)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"
|
2016-04-25 07:26:32 +08:00
|
|
|
[ "_$OUTPUT" = "_pattern_received:_foo_" ] \
|
2014-09-29 09:02:33 +08:00
|
|
|
|| 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
|
|
|
OUTPUT="$(nvm_remote_version iojs-foo)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version iojs-foo >/dev/null 2>&1 ; echo $?)"
|
2016-04-25 07:26:32 +08:00
|
|
|
[ "_$OUTPUT" = "_iojs_pattern_received:_iojs-foo_" ] \
|
2015-01-13 18:22:22 +08:00
|
|
|
|| 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"
|
|
|
|
|
2015-02-11 06:41:45 +08:00
|
|
|
OUTPUT="$(nvm_remote_version iojs)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version iojs >/dev/null 2>&1 ; echo $?)"
|
2016-04-25 07:26:32 +08:00
|
|
|
[ "_$OUTPUT" = "_iojs_pattern_received:__" ] \
|
2015-02-11 06:41:45 +08:00
|
|
|
|| die "nvm_remote_version iojs did not return last line only of nvm_ls_remote_iojs; got $OUTPUT"
|
|
|
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version iojs did not exit with 0, got $EXIT_CODE"
|
|
|
|
|
2015-01-24 02:59:49 +08:00
|
|
|
OUTPUT="$(nvm_remote_version stable)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version stable >/dev/null 2>&1 ; echo $?)"
|
|
|
|
[ "_$OUTPUT" = "_$(nvm_ls_remote stable)" ] \
|
|
|
|
|| die "nvm_remote_version stable did not return contents of nvm_ls_remote stable; got $OUTPUT"
|
|
|
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version stable did not exit with 0, got $EXIT_CODE"
|
|
|
|
|
2015-02-11 06:41:45 +08:00
|
|
|
OUTPUT="$(nvm_remote_version unstable)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version unstable >/dev/null 2>&1 ; echo $?)"
|
|
|
|
[ "_$OUTPUT" = "_$(nvm_ls_remote unstable)" ] \
|
|
|
|
|| die "nvm_remote_version unstable did not return contents of nvm_ls_remote unstable; got $OUTPUT"
|
|
|
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version unstable did not exit with 0, got $EXIT_CODE"
|
2014-09-29 09:02:33 +08:00
|
|
|
|
2015-02-11 06:41:45 +08:00
|
|
|
OUTPUT="$(nvm_remote_version node)"
|
|
|
|
EXIT_CODE="$(nvm_remote_version node >/dev/null 2>&1 ; echo $?)"
|
|
|
|
[ "_$OUTPUT" = "_$(nvm_ls_remote node)" ] \
|
|
|
|
|| die "nvm_remote_version node did not return contents of nvm_ls_remote node; got $OUTPUT"
|
|
|
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version node did not exit with 0, got $EXIT_CODE"
|
|
|
|
|
|
|
|
cleanup
|