From cea0e88489a949b7ee283cf0141b79dd966406a8 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 28 Sep 2014 22:43:46 -0700 Subject: [PATCH] Adding nvm_print_implicit_alias error tests. --- .../nvm_print_implicit_alias errors | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 test/fast/Unit tests/nvm_print_implicit_alias errors diff --git a/test/fast/Unit tests/nvm_print_implicit_alias errors b/test/fast/Unit tests/nvm_print_implicit_alias errors new file mode 100755 index 0000000..44db71c --- /dev/null +++ b/test/fast/Unit tests/nvm_print_implicit_alias errors @@ -0,0 +1,26 @@ +#!/bin/sh + +die () { echo $@ ; exit 1; } + +. ../../../nvm.sh + +EXPECTED_FIRST_MSG="nvm_print_implicit_alias must be specified with local or remote as the first argument." +[ "_$(nvm_print_implicit_alias 2>&1)" = "_$EXPECTED_FIRST_MSG" ] \ + || die "nvm_print_implicit_alias did not require local|remote as first argument" +[ "_$(nvm_print_implicit_alias foo 2>&1)" = "_$EXPECTED_FIRST_MSG" ] \ + || die "nvm_print_implicit_alias did not require local|remote as first argument" + +FIRST_EXIT_CODE="$(nvm_print_implicit_alias > /dev/null 2>&1 ; echo $?)" +[ "_$FIRST_EXIT_CODE" = "_1" ] \ + || die "nvm_print_implicit_alias without local|remote had wrong exit code: expected 1, got $FIRST_EXIT_CODE" + +EXPECTED_SECOND_MSG="Only implicit aliases 'stable' and 'unstable' are supported." +[ "_$(nvm_print_implicit_alias local 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \ + || die "nvm_print_implicit_alias did not require stable|unstable as second argument" +[ "_$(nvm_print_implicit_alias local foo 2>&1)" = "_$EXPECTED_SECOND_MSG" ] \ + || die "nvm_print_implicit_alias did not require stable|unstable as second argument" + +SECOND_EXIT_CODE="$(nvm_print_implicit_alias local > /dev/null 2>&1 ; echo $?)" +[ "_$SECOND_EXIT_CODE" = "_2" ] \ + || die "nvm_print_implicit_alias without stable|unstable had wrong exit code: expected 2, got $SECOND_EXIT_CODE" +