2015-01-13 18:14:29 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
die () { echo $@ ; cleanup ; exit 1; }
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
unset -f nvm_download
|
|
|
|
}
|
|
|
|
|
2016-11-04 13:15:18 +08:00
|
|
|
\. ../../../nvm.sh
|
2015-01-13 18:14:29 +08:00
|
|
|
|
|
|
|
# sample output at the time the test was written
|
2016-04-20 13:49:49 +08:00
|
|
|
TAB_PATH="$PWD/mocks/iojs.org-dist-index.tab"
|
2015-01-13 18:14:29 +08:00
|
|
|
nvm_download() {
|
2015-10-18 03:05:44 +08:00
|
|
|
cat "$TAB_PATH"
|
2015-01-13 18:14:29 +08:00
|
|
|
}
|
|
|
|
|
2016-04-27 16:25:56 +08:00
|
|
|
EXPECTED_OUTPUT_PATH="$PWD/mocks/nvm_ls_remote_iojs.txt"
|
|
|
|
|
2015-01-13 18:14:29 +08:00
|
|
|
OUTPUT="$(nvm_ls_remote_iojs foo)"
|
|
|
|
EXIT_CODE="$(nvm_ls_remote_iojs 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_iojs)"
|
2016-04-27 16:25:56 +08:00
|
|
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH")"
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote_iojs did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
2015-01-13 18:14:29 +08:00
|
|
|
|
|
|
|
OUTPUT="$(nvm_ls_remote_iojs 1.0)"
|
|
|
|
EXPECTED_OUTPUT="iojs-v1.0.0
|
2015-10-18 03:05:44 +08:00
|
|
|
iojs-v1.0.1
|
|
|
|
iojs-v1.0.2
|
|
|
|
iojs-v1.0.3
|
|
|
|
iojs-v1.0.4"
|
2015-01-13 18:14:29 +08:00
|
|
|
|
|
|
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote_iojs 1.0 did not output 1.0.x versions; got $OUTPUT"
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
|