mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-11 06:41:50 +00:00
39 lines
1002 B
Bash
Executable File
39 lines
1002 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# TODO this test currently takes about 1 minute and will take even longer with the rest of the needed test cases so maybe it shouldn't live in the "fast" tests directory.
|
|
|
|
die () { printf "$@" ; exit 1; }
|
|
|
|
\. ../../../nvm.sh
|
|
|
|
newest_node=$(nvm_remote_version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
|
|
x5='5.12.0'
|
|
|
|
# POSITIVE TEST CASES
|
|
|
|
# INPUT:EXPECTED_OUTPUT
|
|
test_cases="*:$newest_node
|
|
5:$x5
|
|
x:$newest_node
|
|
X:$newest_node
|
|
7.1.0 || 7.3.0 || 7.2.0:7.3.0
|
|
7.1.0 7.3.0 7.2.0:
|
|
5:$x5
|
|
5.x:$x5
|
|
5.x.x:$x5
|
|
5.X:$x5
|
|
5.X.X:$x5
|
|
7.5.0:7.5.0"
|
|
|
|
while [ -n "$test_cases" ]; do
|
|
LINE=$(echo "$test_cases" | head -n1)
|
|
INPUT=$(echo "$LINE" | awk -F: '{ print $1 }')
|
|
EXPECTED_OUTPUT=$(echo "$LINE" | awk -F: '{ print $2 }')
|
|
ACTUAL_OUTPUT=$(nvm_interpret_semver "$INPUT")
|
|
if [ "$ACTUAL_OUTPUT" != "$EXPECTED_OUTPUT" ] || [ -z "$INPUT" ]; then
|
|
die "Expected output: '$EXPECTED_OUTPUT'. Actual output: '$ACTUAL_OUTPUT'. Input: '$INPUT'.\n"
|
|
fi
|
|
test_cases=$(echo "$test_cases" | tail -n +2)
|
|
done
|
|
exit 0
|