-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
185 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
test/fast/Unit tests/Running 'nvm use --save' works as expected'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/sh | ||
\. ../../../nvm.sh | ||
\. ../../common.sh | ||
|
||
set -e | ||
|
||
TEST_VERSION='v0.2.4' | ||
|
||
if [ -f .nvmrc ]; then mv .nvmrc .nvmrc.orig; fi | ||
|
||
cleanup() { | ||
nvm cache clear | ||
nvm deactivate | ||
nvm unalias default | ||
rm -rf "${NVM_DIR}/v0.2.4" .nvmrc | ||
if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi | ||
unset -f nvm_ls_remote nvm_ls_remote_iojs | ||
} | ||
|
||
die() { | ||
echo "$@" | ||
cleanup | ||
exit 1 | ||
} | ||
|
||
REMOTE="${PWD}/mocks/nvm_ls_remote.txt" | ||
nvm_ls_remote() { | ||
if [ -n "${PATTERN}" ]; then | ||
cat "${REMOTE}" | \grep "${PATTERN}" | ||
else | ||
cat "${REMOTE}" | ||
fi | ||
} | ||
REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt" | ||
nvm_ls_remote_iojs() { | ||
local PATTERN | ||
PATTERN="${1-}" | ||
if [ -n "${PATTERN}" ]; then | ||
cat "${REMOTE_IOJS}" | \grep "${PATTERN}" | ||
else | ||
cat "${REMOTE_IOJS}" | ||
fi | ||
} | ||
|
||
make_fake_node "${TEST_VERSION}" | ||
|
||
nvm use -w "${TEST_VERSION}" || die "\`nvm install -w ${TEST_VERSION}\` failed" | ||
OUTPUT="$(cat .nvmrc)" | ||
|
||
nvm_is_valid_version "${OUTPUT}" \ | ||
|| die "\`nvm install -w ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'" | ||
|
||
rm .nvmrc || die 'removing of .nvmrc failed' | ||
|
||
nvm use --save "${TEST_VERSION}" || die "\`nvm install --save ${TEST_VERSION}\` failed" | ||
OUTPUT="$(cat .nvmrc)" | ||
|
||
nvm_is_valid_version "${OUTPUT}" \ | ||
|| die "\`nvm install --save ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'" | ||
|
||
cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
test/fast/Unit tests/Running 'nvm use -w' works as expected'
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.