forked from nvm-sh/nvm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nvm-sh#150 from tlevine/master
I added tests.
- Loading branch information
Showing
17 changed files
with
149 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ HEAD | |
src | ||
v* | ||
alias | ||
|
||
# For testing | ||
bak | ||
.urchin.log |
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
4 changes: 4 additions & 0 deletions
4
test/fast/Aliases/Running "nvm alias <aliasname>" should list but one alias.
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,4 @@ | ||
#!/bin/sh | ||
|
||
. ../../../nvm.sh | ||
[ $(nvm alias test1 | wc -l) = '2' ] |
4 changes: 4 additions & 0 deletions
4
test/fast/Aliases/Running "nvm alias" should list all aliases.
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,4 @@ | ||
#!/bin/sh | ||
|
||
. ../../../nvm.sh | ||
[ $(nvm alias | wc -l) = '10' ] |
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,6 @@ | ||
#!/bin/sh | ||
|
||
for i in $(seq 1 10) | ||
do | ||
echo v0.0.$i > ../../../alias/test$i | ||
done |
10 changes: 10 additions & 0 deletions
10
test/fast/Listing versions/Running "nvm ls 0.2" should display only 0.2.x versions.
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,10 @@ | ||
#!/bin/sh | ||
|
||
mkdir ../../../v0.1.3 | ||
mkdir ../../../v0.2.3 | ||
|
||
. ../../../nvm.sh | ||
|
||
# The result should contain only the appropriate version numbers. | ||
nvm ls 0.2 | grep v0.2.3 && | ||
nvm ls 0.1 | grep -v v0.2.3 |
14 changes: 14 additions & 0 deletions
14
test/fast/Listing versions/Running "nvm ls" should display all installed versions.
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,14 @@ | ||
#!/bin/sh | ||
|
||
. ../../../nvm.sh | ||
|
||
mkdir ../../../v0.0.{1,3,9} | ||
mkdir ../../../v0.3.{1,3,9} | ||
|
||
# The result should contain the version numbers. | ||
nvm ls | grep v0.0.1 && | ||
nvm ls | grep v0.0.3 && | ||
nvm ls | grep v0.0.9 && | ||
nvm ls | grep v0.3.1 && | ||
nvm ls | grep v0.3.3 && | ||
nvm ls | grep v0.3.9 |
5 changes: 5 additions & 0 deletions
5
test/fast/Running "nvm alias" should create a file in the alias directory.
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,5 @@ | ||
#!/bin/sh | ||
|
||
. ../../nvm.sh | ||
nvm alias test v0.1.2 | ||
[ $(cat ../../alias/test) = 'v0.1.2' ] |
6 changes: 6 additions & 0 deletions
6
test/fast/Running "nvm deactivate" should unset the nvm environment variables.
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,6 @@ | ||
#!/bin/sh | ||
|
||
. ../../nvm.sh | ||
nvm && | ||
nvm deactivate && | ||
! nvm |
6 changes: 6 additions & 0 deletions
6
test/fast/Running "nvm unalias" should remove the alias file.
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,6 @@ | ||
#!/bin/sh | ||
|
||
echo v0.1.2 > ../../alias/test | ||
. ../../nvm.sh | ||
nvm unalias test | ||
! [ -e ../../alias/test ] |
10 changes: 10 additions & 0 deletions
10
test/fast/Running "nvm uninstall" should remove the appropriate directory.
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,10 @@ | ||
#!/bin/sh | ||
|
||
cd ../.. | ||
mkdir v0.0.1 | ||
mkdir src/node-v0.0.1 | ||
|
||
. ./nvm.sh | ||
nvm uninstall v0.0.1 | ||
|
||
[ ! -d 'v0.0.1' ] && [ ! -d 'src/node-v0.0.1' ] |
4 changes: 4 additions & 0 deletions
4
test/fast/Sourcing nvm.sh should make the nvm command available.
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,4 @@ | ||
#!/bin/sh | ||
|
||
. ../../nvm.sh | ||
nvm |
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,9 @@ | ||
#!/bin/sh | ||
|
||
( | ||
cd ../.. | ||
|
||
# Back up | ||
rm -Rf v* src alias | ||
mkdir src alias | ||
) |
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,9 @@ | ||
#!/bin/sh | ||
|
||
( | ||
cd ../.. | ||
|
||
# Back up | ||
mkdir -p bak | ||
mv v* src alias bak || sleep 0s | ||
) |
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,7 @@ | ||
#!/bin/sh | ||
|
||
# Remove temporary files | ||
( | ||
cd ../.. | ||
rm -fR v* src alias | ||
) |
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,13 @@ | ||
#!/bin/sh | ||
|
||
( | ||
cd ../.. | ||
|
||
# Restore | ||
if [ -d bak ] | ||
then | ||
mv bak/* . || sleep 0s | ||
rmdir bak | ||
fi | ||
mkdir -p src alias | ||
) |
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,14 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
. ../../nvm.sh | ||
|
||
# Remove the stuff we're clobbering. | ||
[ -e ../../v0.6.14 ] && rm -R ../../v0.6.14 | ||
|
||
# Install | ||
nvm install 0.6.14 | ||
|
||
# Check | ||
[ -d ../../v0.6.14 ] | ||
nvm run v0.6.14 --version | grep v0.6.14 |