mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-17 17:41:50 +00:00
port 4 more list tests
This commit is contained in:
parent
36b0251e5b
commit
01d2a3faf8
@ -3,7 +3,7 @@
|
|||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
NVM_SRC_DIR="${BATS_TEST_DIRNAME}/../.."
|
NVM_SRC_DIR="${BATS_TEST_DIRNAME}/../.."
|
||||||
load "${NVM_SRC_DIR}/nvm.sh"
|
source "${NVM_SRC_DIR}/nvm.sh"
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
echo 'setup' >&2
|
echo 'setup' >&2
|
||||||
@ -44,3 +44,50 @@ teardown() {
|
|||||||
assert_nomatch "$output" "v0.0.20" "nvm ls 0.0.2 must NOT contain v0.0.20"
|
assert_nomatch "$output" "v0.0.20" "nvm ls 0.0.2 must NOT contain v0.0.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test './Listing versions/Running "nvm ls 0.2" should display only 0.2.x versions.' {
|
||||||
|
|
||||||
|
mkdir -p v0.1.3
|
||||||
|
mkdir -p v0.2.3
|
||||||
|
mkdir -p v0.20.3
|
||||||
|
|
||||||
|
run nvm ls 0.1
|
||||||
|
assert_nomatch "$output" "v0.2.3" "nvm ls 0.1 should not contain v0.2.3"
|
||||||
|
assert_nomatch "$output" "v0.20.3" "nvm ls 0.1 should not contain v0.20.3"
|
||||||
|
assert_match "$output" "v0.1.3" "nvm ls 0.1 should contain v0.1.3"
|
||||||
|
|
||||||
|
run nvm ls 0.2
|
||||||
|
assert_match "$output" "v0.2.3" "nvm ls 0.2 should contain v0.2.3"
|
||||||
|
assert_nomatch "$output" "v0.20.3" "nvm ls 0.2 should not contain v0.20.3"
|
||||||
|
assert_nomatch "$output" "v0.1.3" "nvm ls 0.2 should not contain v0.1.3"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test './Listing versions/Running "nvm ls foo" should return a nonzero exit code when not found' {
|
||||||
|
|
||||||
|
run nvm ls nonexistent_version
|
||||||
|
assert_equal 3 "$status"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test './Listing versions/Running "nvm ls node" should return a nonzero exit code when not found' {
|
||||||
|
|
||||||
|
run nvm ls node
|
||||||
|
assert_equal 3 "$status"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test './Listing versions/Running "nvm ls stable" and "nvm ls unstable" should return the appropriate implicit alias' {
|
||||||
|
|
||||||
|
mkdir -p v0.2.3
|
||||||
|
mkdir -p v0.3.3
|
||||||
|
|
||||||
|
run nvm ls stable
|
||||||
|
assert_match "$output" "0.2.3" "expected 'nvm ls stable' to give STABLE_VERSION"
|
||||||
|
|
||||||
|
run nvm ls unstable
|
||||||
|
assert_match "$output" "0.3.3" "expected 'nvm ls unstable' to give UNSTABLE_VERSION"
|
||||||
|
mkdir -p v0.1.2
|
||||||
|
nvm alias stable 0.1
|
||||||
|
|
||||||
|
run nvm ls stable
|
||||||
|
assert_nomatch "$output" "0.2.3" "expected 'nvm ls stable' to not give old STABLE_VERSION"
|
||||||
|
assert_match "$output" "v0.1.2" "expected 'nvm ls stable' to give new STABLE_VERSION"
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -18,126 +18,6 @@ teardown() {
|
|||||||
rm -Rf src alias v*
|
rm -Rf src alias v*
|
||||||
}
|
}
|
||||||
|
|
||||||
@test './Listing versions/Running "nvm ls 0.0.2" should display only version 0.0.2.' {
|
|
||||||
##!/bin/sh
|
|
||||||
#
|
|
||||||
#mkdir ../../../v0.0.2
|
|
||||||
#mkdir ../../../v0.0.20
|
|
||||||
#
|
|
||||||
#. ../../../nvm.sh
|
|
||||||
#
|
|
||||||
#die () { echo $@ ; exit 1; }
|
|
||||||
#
|
|
||||||
## The result should contain only the appropriate version numbers.
|
|
||||||
#
|
|
||||||
#nvm ls 0.0.2 | grep 'v0.0.2' > /dev/null
|
|
||||||
#if [ $? -eq 0 ]; then
|
|
||||||
# echo '"nvm ls 0.0.2" contained v0.0.2'
|
|
||||||
#fi
|
|
||||||
#
|
|
||||||
#nvm ls 0.0.2 | grep 'v0.0.20' > /dev/null
|
|
||||||
#if [ $? -eq 0 ]; then
|
|
||||||
# die '"nvm ls 0.0.2" contained v0.0.20'
|
|
||||||
#fi
|
|
||||||
#
|
|
||||||
}
|
|
||||||
|
|
||||||
@test './Listing versions/Running "nvm ls 0.2" should display only 0.2.x versions.' {
|
|
||||||
##!/bin/sh
|
|
||||||
#
|
|
||||||
#mkdir ../../../v0.1.3
|
|
||||||
#mkdir ../../../v0.2.3
|
|
||||||
#mkdir ../../../v0.20.3
|
|
||||||
#
|
|
||||||
#. ../../../nvm.sh
|
|
||||||
#
|
|
||||||
#die () { echo $@ ; exit 1; }
|
|
||||||
#
|
|
||||||
## The result should contain only the appropriate version numbers.
|
|
||||||
#
|
|
||||||
#nvm ls 0.1 | grep 'v0.2.3' > /dev/null
|
|
||||||
#if [ $? -eq 0 ]; then
|
|
||||||
# echo '"nvm ls 0.1" contained v0.2.3'
|
|
||||||
#fi
|
|
||||||
#
|
|
||||||
#nvm ls 0.1 | grep 'v0.20.3' > /dev/null
|
|
||||||
#if [ $? -eq 0 ]; then
|
|
||||||
# die '"nvm ls 0.1" contained v0.20.3'
|
|
||||||
#fi
|
|
||||||
#
|
|
||||||
#nvm ls 0.1 | grep 'v0.1.3' > /dev/null
|
|
||||||
#if [ $? -ne 0 ]; then
|
|
||||||
# die '"nvm ls 0.1" did not contain v0.1.3'
|
|
||||||
#fi
|
|
||||||
#
|
|
||||||
#nvm ls 0.2 | grep 'v0.2.3' > /dev/null
|
|
||||||
#if [ $? -ne 0 ]; then
|
|
||||||
# die '"nvm ls 0.2" did not contain v0.2.3'
|
|
||||||
#fi
|
|
||||||
#
|
|
||||||
#nvm ls 0.2 | grep 'v0.20.3' > /dev/null
|
|
||||||
#if [ $? -eq 0 ]; then
|
|
||||||
# die '"nvm ls 0.2" contained v0.20.3'
|
|
||||||
#fi
|
|
||||||
#
|
|
||||||
#nvm ls 0.2 | grep 'v0.2.3' > /dev/null
|
|
||||||
#if [ $? -ne 0 ]; then
|
|
||||||
# die '"nvm ls 0.2" did not contain v0.2.3'
|
|
||||||
#fi
|
|
||||||
}
|
|
||||||
|
|
||||||
@test './Listing versions/Running "nvm ls foo" should return a nonzero exit code when not found' {
|
|
||||||
# #!/bin/sh
|
|
||||||
#
|
|
||||||
#. ../../../nvm.sh
|
|
||||||
#
|
|
||||||
#nvm ls nonexistent_version
|
|
||||||
#[ "$?" = "3" ]
|
|
||||||
#
|
|
||||||
}
|
|
||||||
|
|
||||||
@test './Listing versions/Running "nvm ls node" should return a nonzero exit code when not found' {
|
|
||||||
# #!/bin/sh
|
|
||||||
#
|
|
||||||
#. ../../../nvm.sh
|
|
||||||
#
|
|
||||||
#nvm ls node
|
|
||||||
#[ "$?" = "3" ]
|
|
||||||
#
|
|
||||||
}
|
|
||||||
|
|
||||||
@test './Listing versions/Running "nvm ls stable" and "nvm ls unstable" should return the appropriate implicit alias' {
|
|
||||||
# #!/bin/sh
|
|
||||||
#
|
|
||||||
#. ../../../nvm.sh
|
|
||||||
#
|
|
||||||
#die () { echo $@ ; exit 1; }
|
|
||||||
#
|
|
||||||
#mkdir ../../../v0.2.3
|
|
||||||
#mkdir ../../../v0.3.3
|
|
||||||
#
|
|
||||||
#EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
|
||||||
#STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
|
||||||
#
|
|
||||||
#EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
|
||||||
#UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
|
||||||
#
|
|
||||||
#nvm ls stable | \grep "$STABLE_VERSION" >/dev/null \
|
|
||||||
# || die "expected 'nvm ls stable' to give $STABLE_VERSION, got $(nvm ls stable)"
|
|
||||||
#
|
|
||||||
#nvm ls unstable | \grep "$UNSTABLE_VERSION" >/dev/null \
|
|
||||||
# || die "expected 'nvm ls unstable' to give $UNSTABLE_VERSION, got $(nvm ls unstable)"
|
|
||||||
#
|
|
||||||
#mkdir ../../../v0.1.2
|
|
||||||
#nvm alias stable 0.1
|
|
||||||
#
|
|
||||||
#nvm ls stable | \grep -v "$STABLE_VERSION" >/dev/null \
|
|
||||||
# || die "'nvm ls stable' contained $STABLE_VERSION instead of v0.1.2"
|
|
||||||
#nvm ls stable | \grep v0.1.2 >/dev/null \
|
|
||||||
# || die "'nvm ls stable' did not contain v0.1.2"
|
|
||||||
#
|
|
||||||
}
|
|
||||||
|
|
||||||
@test './Listing versions/Running "nvm ls system" should include "system" when appropriate' {
|
@test './Listing versions/Running "nvm ls system" should include "system" when appropriate' {
|
||||||
##!/bin/sh
|
##!/bin/sh
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user