You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							57 lines
						
					
					
						
							1.8 KiB
						
					
					
				
			
		
		
	
	
							57 lines
						
					
					
						
							1.8 KiB
						
					
					
				#!/bin/sh | 
						|
 | 
						|
die () { echo $@ ; cleanup ; exit 1; } | 
						|
 | 
						|
cleanup() { | 
						|
  unset -f nvm_download | 
						|
} | 
						|
 | 
						|
. ../../../nvm.sh | 
						|
 | 
						|
# sample output at the time the test was written | 
						|
TAB_PATH="$PWD/nodejs.org-dist-index.tab" | 
						|
nvm_download() { | 
						|
  cat "$TAB_PATH" | 
						|
} | 
						|
 | 
						|
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)" | 
						|
EXPECTED_OUTPUT="$(nvm_download | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n)" | 
						|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm_ls_remote did not output expected sorted versions; got $(echo "$OUTPUT") expected $(echo "$EXPECTED_OUTPUT")" | 
						|
 | 
						|
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" | 
						|
 | 
						|
# Sanity checks | 
						|
OUTPUT="$(nvm_print_implicit_alias remote stable)" | 
						|
EXPECTED_OUTPUT="4.2" | 
						|
[ "_$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)" | 
						|
EXPECTED_OUTPUT="v4.2.1" | 
						|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote stable did not output $EXPECTED_OUTPUT; got $OUTPUT" | 
						|
 | 
						|
OUTPUT="$(nvm_ls_remote unstable)" | 
						|
EXPECTED_OUTPUT="v0.11.16" | 
						|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm_ls_remote unstable did not output $EXPECTED_OUTPUT; got $OUTPUT" | 
						|
 | 
						|
cleanup | 
						|
 | 
						|
 |