From b8fe75e93a58662bd0b548eb3f61b6307a60210a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 31 Jul 2014 19:46:08 -0700 Subject: [PATCH] Tests for `nvm copy-packages` --- test/slow/nvm copy-packages/setup_dir | 10 +++++++++ .../nvm copy-packages/should work as expected | 21 +++++++++++++++++++ test/slow/nvm copy-packages/teardown_dir | 12 +++++++++++ 3 files changed, 43 insertions(+) create mode 100755 test/slow/nvm copy-packages/setup_dir create mode 100755 test/slow/nvm copy-packages/should work as expected create mode 100755 test/slow/nvm copy-packages/teardown_dir diff --git a/test/slow/nvm copy-packages/setup_dir b/test/slow/nvm copy-packages/setup_dir new file mode 100755 index 0000000..c550f69 --- /dev/null +++ b/test/slow/nvm copy-packages/setup_dir @@ -0,0 +1,10 @@ +#!/bin/sh + +. ../../../nvm.sh +nvm install 0.10.28 +nvm install 0.10.29 + +if [ -f ".nvmrc" ]; then + mv .nvmrc .nvmrc.bak +fi + diff --git a/test/slow/nvm copy-packages/should work as expected b/test/slow/nvm copy-packages/should work as expected new file mode 100755 index 0000000..21f10df --- /dev/null +++ b/test/slow/nvm copy-packages/should work as expected @@ -0,0 +1,21 @@ +#!/bin/sh + +die () { echo "$@" ; exit 1; } + +. ../../../nvm.sh + +nvm use 0.10.28 + +EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp npm recursive-blame uglify-js yo" + +npm install -g --quiet $EXPECTED_PACKAGES + +nvm use 0.10.29 +ORIGINAL_PACKAGES=$(npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | grep -o -e '/[^/]*$' | cut -c 2- | sort | uniq | xargs) + +nvm copy-packages 0.10.28 +FINAL_PACKAGES=$(npm list --global --parseable --depth=0 2> /dev/null | tail -n +2 | grep -o -e '/[^/]*$' | cut -c 2- | sort | uniq | xargs) + +[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)" +[ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)" + diff --git a/test/slow/nvm copy-packages/teardown_dir b/test/slow/nvm copy-packages/teardown_dir new file mode 100755 index 0000000..1282eb4 --- /dev/null +++ b/test/slow/nvm copy-packages/teardown_dir @@ -0,0 +1,12 @@ +#!/bin/sh + +. ../../../nvm.sh +nvm uninstall v0.10.28 +nvm uninstall v0.10.29 + +rm -f .nvmrc + +if [ -f ".nvmrc.bak" ]; then + mv .nvmrc.bak .nvmrc +fi +