Skip to content
Myr

Adding unit tests for --silent

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Alan Quach · committed by Alan Quach · parent 98e40a8 · Browse files · 6 files+39 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+39 added−0 removed

  • tests:+39 added−0 removed

6 files+39 added−0 removed

modified:test/fast/Running "nvm use foo" where "foo" is circular aborts+8 added
16 unmodified lines
1718EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"19[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"2021OUTPUT="$(nvm use --silent foo 2>&1)"22EXPECTED_OUTPUT=''23[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \24 || die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"2526EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)"27[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE"2829cleanup;30
modified:test/fast/Running "nvm use iojs" uses latest io.js version+8 added
16 unmodified lines
1718EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"19[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"2021OUTPUT="$(nvm use --silent foo 2>&1)"22EXPECTED_OUTPUT=''23[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \24 || die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"2526EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)"27[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE"2829cleanup;30
modified:test/fast/Running "nvm use system" should work as expected+5 added
6 unmodified lines
7nvm_has_system_node() { return 0; }8nvm_print_npm_version() { return ' (npm v1.2.3)'; }9EXPECTED_OUTPUT="Now using system version of node: $(node -v)$(nvm_print_npm_version)"10[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node"11EXPECTED_OUTPUT=""12[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node or --silent was not silent"1314nvm_has_system_node() { return 1; }15nvm_print_npm_version() { return ''; }16EXPECTED_OUTPUT="System version of node not found."17[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found"18nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"19EXPECTED_OUTPUT=""20[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found or --silent was not silent"21nvm use --silent system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found or --silent was not silent"22
modified:test/slow/nvm use/Running "nvm use iojs" uses latest io.js version+6 added
10 unmodified lines
11EXPECTED_OUTPUT="iojs-v1.0.1"1213[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \14 || die "'nvm use iojs' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"1516OUTPUT="$(nvm use --silent iojs)"17EXPECTED_OUTPUT=""1819[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \20 || die "'nvm use --silent iojs' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'"
modified:test/slow/nvm use/Running "nvm use node" uses latest stable node version+6 added
10 unmodified lines
11EXPECTED_OUTPUT="$(nvm_version stable)"1213[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \14 || die "'nvm use node' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"1516OUTPUT="$(nvm use --silent node)"17EXPECTED_OUTPUT=""1819[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \20 || die "'nvm use --silent node' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'"
modified:test/slow/nvm use/Running "nvm use v1.0.0" uses iojs-v1.0.0 iojs version+6 added
10 unmodified lines
11EXPECTED_OUTPUT="$(nvm_version v1.0.0)"1213[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \14 || die "'nvm use v1.0.0' + 'nvm current' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"1516OUTPUT="$(nvm use --silent 'v1.0.0')"17EXPECTED_OUTPUT=""1819[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \20 || die "'nvm use --silent v1.0.0' output was not silenced '$EXPECTED_OUTPUT'; got '$OUTPUT'"