2014-09-29 13:00:20 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
die () { echo $@ ; cleanup ; exit 1; }
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
unset -f nvm_download
|
|
|
|
}
|
|
|
|
|
|
|
|
. ../../../nvm.sh
|
|
|
|
|
2016-04-24 14:47:25 +08:00
|
|
|
MOCKS_DIR="$PWD/mocks"
|
|
|
|
|
2014-09-29 13:00:20 +08:00
|
|
|
# sample output at the time the test was written
|
2016-04-24 14:47:25 +08:00
|
|
|
TAB_PATH="$MOCKS_DIR/nodejs.org-dist-index.tab"
|
2014-09-29 13:00:20 +08:00
|
|
|
nvm_download() {
|
2015-10-18 01:34:42 +08:00
|
|
|
cat "$TAB_PATH"
|
2014-09-29 13:00:20 +08:00
|
|
|
}
|
|
|
|
|
2016-04-24 14:47:25 +08:00
|
|
|
EXPECTED_OUTPUT_PATH="$MOCKS_DIR/nvm_ls_remote.txt"
|
2016-04-27 16:25:56 +08:00
|
|
|
|
2014-09-29 13:00:20 +08:00
|
|
|
OUTPUT="$(nvm_ls_remote foo)"
|
|
|
|
EXIT_CODE="$(nvm_ls_remote foo >/dev/null 2>&1 ; echo $?)"
|
|
|
|
[ "_$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"
|
|
|
|
|
|
|
|
OUTPUT="$(nvm_ls_remote)"
|
2016-04-27 16:25:56 +08:00
|
|
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH")"
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
2014-09-29 13:00:20 +08:00
|
|
|
|
|
|
|
OUTPUT="$(nvm_ls_remote 0.3)"
|
|
|
|
EXPECTED_OUTPUT="v0.3.0
|
|
|
|
v0.3.1
|
|
|
|
v0.3.2
|
|
|
|
v0.3.3
|
|
|
|
v0.3.4
|
|
|
|
v0.3.5
|
|
|
|
v0.3.6
|
|
|
|
v0.3.7
|
|
|
|
v0.3.8"
|
|
|
|
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote 0.3 did not output 0.3.x versions; got $OUTPUT"
|
|
|
|
|
2014-09-29 15:10:06 +08:00
|
|
|
# Sanity checks
|
|
|
|
OUTPUT="$(nvm_print_implicit_alias remote stable)"
|
2016-06-26 08:03:46 +08:00
|
|
|
EXPECTED_OUTPUT="6.2"
|
2014-09-29 15:10:06 +08:00
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
|
|
|
|
|
|
|
OUTPUT="$(nvm_print_implicit_alias remote unstable)"
|
|
|
|
EXPECTED_OUTPUT="0.11"
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_print_implicit_alias remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
|
|
|
|
|
|
|
OUTPUT="$(nvm_ls_remote stable)"
|
2016-06-26 08:03:46 +08:00
|
|
|
EXPECTED_OUTPUT="v6.2.2"
|
2014-09-29 15:10:06 +08:00
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
|
|
|
|
|
|
|
OUTPUT="$(nvm_ls_remote unstable)"
|
2015-10-18 01:34:42 +08:00
|
|
|
EXPECTED_OUTPUT="v0.11.16"
|
2014-09-29 15:10:06 +08:00
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT"
|
|
|
|
|
2016-04-24 14:47:25 +08:00
|
|
|
EXPECTED_OUTPUT_PATH="$MOCKS_DIR/nvm_ls_remote LTS.txt"
|
|
|
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH")"
|
|
|
|
OUTPUT="$(NVM_LTS='*' nvm_ls_remote)"
|
|
|
|
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "\`NVM_LTS='*' nvm_ls_remote\` did not output >$EXPECTED_OUTPUT<; got >$OUTPUT<"
|
|
|
|
|
|
|
|
EXPECTED_OUTPUT_PATH="$MOCKS_DIR/nvm_ls_remote LTS argon.txt"
|
|
|
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH")"
|
|
|
|
OUTPUT="$(NVM_LTS=argon nvm_ls_remote)"
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "\`NVM_LTS=argon nvm_ls_remote\` did not output >$EXPECTED_OUTPUT<; got >$OUTPUT<"
|
|
|
|
|
2014-09-29 13:00:20 +08:00
|
|
|
cleanup
|