[Tests] fix failing test
parent
aa57406ede
commit
5cc74a6736
|
@ -13,6 +13,8 @@ nvm_alias_path() {
|
||||||
nvm_echo "../../../alias"
|
nvm_echo "../../../alias"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm ls-remote >/dev/null || die 'nvm ls-remote (to populate LTS aliases) failed'
|
||||||
|
|
||||||
MOCKS_DIR="../Unit tests/mocks"
|
MOCKS_DIR="../Unit tests/mocks"
|
||||||
|
|
||||||
EXPECTED_OUTPUT="$(cat "$MOCKS_DIR/lts-star.txt")"
|
EXPECTED_OUTPUT="$(cat "$MOCKS_DIR/lts-star.txt")"
|
||||||
|
|
|
@ -22,6 +22,40 @@ nvm deactivate 2>/dev/null || die 'unable to deactivate'
|
||||||
|
|
||||||
\. ../../common.sh
|
\. ../../common.sh
|
||||||
|
|
||||||
|
MOCKS_DIR="$PWD/mocks"
|
||||||
|
|
||||||
|
nvm_download() {
|
||||||
|
if [ "$*" = "-L -s $(nvm_get_mirror node std)/index.tab -o -" ]; then
|
||||||
|
cat "$MOCKS_DIR/nodejs.org-dist-index.tab"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
return 42
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
|
||||||
|
OUTPUT="$(nvm ls-remote --lts | sed 's/[ \t]*$//')"
|
||||||
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote --lts did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
||||||
|
|
||||||
|
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
|
||||||
|
OUTPUT="$(nvm ls-remote "lts/*" | sed 's/[ \t]*$//')"
|
||||||
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
||||||
|
|
||||||
|
MOCKS_DIR="$PWD/mocks"
|
||||||
|
LTS_NAMES_PATH="${MOCKS_DIR}/LTS_names.txt"
|
||||||
|
LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)"
|
||||||
|
|
||||||
|
INDEX=1
|
||||||
|
printf '%s\n' "${LTS_LIST}" | while IFS= read -r LTS; do
|
||||||
|
ACTUAL="$(nvm ls-remote "lts/-${INDEX}" | sed 's/[ \t]*$//')"
|
||||||
|
MESSAGE="for lts/-${INDEX} (${LTS})"
|
||||||
|
EXPECTED="$(nvm ls-remote "lts/${LTS}" | sed 's/[ \t]*$//')"
|
||||||
|
[ "${ACTUAL}" = "${EXPECTED}" ] || die "${MESSAGE}: expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||||
|
|
||||||
|
INDEX=$(($INDEX + 1))
|
||||||
|
done
|
||||||
|
|
||||||
REMOTE="$PWD/mocks/nvm_ls_remote.txt"
|
REMOTE="$PWD/mocks/nvm_ls_remote.txt"
|
||||||
nvm_ls_remote() {
|
nvm_ls_remote() {
|
||||||
cat "$REMOTE"
|
cat "$REMOTE"
|
||||||
|
@ -31,39 +65,9 @@ nvm_ls_remote_iojs() {
|
||||||
cat "$REMOTE_IOJS"
|
cat "$REMOTE_IOJS"
|
||||||
}
|
}
|
||||||
|
|
||||||
MOCKS_DIR="$PWD/mocks"
|
|
||||||
|
|
||||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote.txt"
|
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote.txt"
|
||||||
OUTPUT="$(nvm ls-remote | sed 's/[ \t]*$//')"
|
OUTPUT="$(nvm ls-remote | sed 's/[ \t]*$//')"
|
||||||
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm ls-remote did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm ls-remote did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
||||||
|
|
||||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
|
|
||||||
OUTPUT="$(nvm ls-remote --lts="*" | sed 's/[ \t]*$//')"
|
|
||||||
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote --lts=* did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
|
||||||
|
|
||||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
|
|
||||||
OUTPUT="$(nvm ls-remote "lts/*" | sed 's/[ \t]*$//')"
|
|
||||||
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
|
||||||
|
|
||||||
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
|
|
||||||
OUTPUT="$(nvm ls-remote "lts/-1" | sed 's/[ \t]*$//')"
|
|
||||||
EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"
|
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"
|
|
||||||
|
|
||||||
LTS_NAMES_PATH="${MOCKS_DIR}/LTS_names.txt"
|
|
||||||
LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)"
|
|
||||||
|
|
||||||
INDEX=1
|
|
||||||
for LTS in $LTS_LIST; do
|
|
||||||
ACTUAL="$(nvm ls-remote "lts/-${INDEX}" | sed 's/[ \t]*$//')"
|
|
||||||
MESSAGE="for lts/-${INDEX} / ${LTS}"
|
|
||||||
EXPECTED="$(nvm ls-remote "lts/${LTS}" | sed 's/[ \t]*$//')"
|
|
||||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "${MESSAGE}: expected >${EXPECTED}<, got >${ACTUAL}<"
|
|
||||||
|
|
||||||
INDEX=$(($INDEX + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
|
@ -28,9 +28,9 @@ LTS_NAMES_PATH="${MOCKS_DIR}/LTS_names.txt"
|
||||||
LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)"
|
LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)"
|
||||||
|
|
||||||
INDEX=1
|
INDEX=1
|
||||||
for LTS in $LTS_LIST; do
|
printf '%s\n' "${LTS_LIST}" | while IFS= read -r LTS; do
|
||||||
ACTUAL="$(nvm_normalize_lts "lts/-${INDEX}")"
|
ACTUAL="$(nvm_normalize_lts "lts/-${INDEX}")"
|
||||||
MESSAGE="for lts/-${INDEX}"
|
MESSAGE="for lts/-${INDEX} (${LTS})"
|
||||||
EXPECTED="lts/$(echo "${LTS_LIST}" | tail -n +${INDEX} | head -n1)"
|
EXPECTED="lts/$(echo "${LTS_LIST}" | tail -n +${INDEX} | head -n1)"
|
||||||
[ "${ACTUAL}" = "${EXPECTED}" ] || die "${MESSAGE}: expected >${EXPECTED}<, got >${ACTUAL}<"
|
[ "${ACTUAL}" = "${EXPECTED}" ] || die "${MESSAGE}: expected >${EXPECTED}<, got >${ACTUAL}<"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue