2021-12-17 14:55:02 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
unset nvm_get_os
|
|
|
|
}
|
|
|
|
|
|
|
|
die () { cleanup; echo "$@" ; exit 1; }
|
|
|
|
|
|
|
|
\. ../../../nvm.sh
|
|
|
|
|
|
|
|
ACTUAL="$(nvm_normalize_lts "foo")"
|
|
|
|
EXPECTED='foo'
|
|
|
|
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
|
|
|
|
|
|
|
ACTUAL="$(nvm_normalize_lts "lts/*")"
|
|
|
|
EXPECTED='lts/*'
|
|
|
|
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
|
|
|
|
|
|
|
|
|
|
|
MOCKS_DIR="../Unit tests/mocks"
|
|
|
|
STAR="$(cat "$MOCKS_DIR/lts-star.txt")"
|
|
|
|
|
|
|
|
ACTUAL="$(nvm_normalize_lts "${STAR}")"
|
|
|
|
EXPECTED="${STAR}"
|
|
|
|
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
|
|
|
|
|
|
|
|
LTS_NAMES_PATH="${MOCKS_DIR}/LTS_names.txt"
|
|
|
|
LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)"
|
|
|
|
|
|
|
|
INDEX=1
|
2021-12-18 05:21:29 +08:00
|
|
|
printf '%s\n' "${LTS_LIST}" | while IFS= read -r LTS; do
|
2021-12-17 14:55:02 +08:00
|
|
|
ACTUAL="$(nvm_normalize_lts "lts/-${INDEX}")"
|
2021-12-18 05:21:29 +08:00
|
|
|
MESSAGE="for lts/-${INDEX} (${LTS})"
|
2021-12-17 14:55:02 +08:00
|
|
|
EXPECTED="lts/$(echo "${LTS_LIST}" | tail -n +${INDEX} | head -n1)"
|
|
|
|
[ "${ACTUAL}" = "${EXPECTED}" ] || die "${MESSAGE}: expected >${EXPECTED}<, got >${ACTUAL}<"
|
|
|
|
|
|
|
|
INDEX=$(($INDEX + 1))
|
|
|
|
done
|