Skip to content
Myr

nvm_alias

This file

Path

test/fast/Unit tests/nvm_alias

31 lines · 997 bytes

Last changed by

[Tests] add `try`/`try_err` helpers; convert tests to use themJordan Harbandbefore adoption14d01c6

History of this file

Take it

1#!/bin/sh23die () { echo "$@" ; cleanup ; exit 1; }45cleanup () {6  rm -rf ../../../alias/test7}89: nvm.sh10\. ../../../nvm.sh1112\. ../../common.sh1314try_err nvm_alias15EXPECTED_OUTPUT='An alias is required.'16[ "_$CAPTURED_STDERR" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias' produced wrong output; got $CAPTURED_STDERR"17[ "_$CAPTURED_EXIT_CODE" = "_1" ] || die "'nvm_alias' exited with $CAPTURED_EXIT_CODE, expected 1"1819rm -rf ../../../alias/nonexistent2021try_err nvm_alias nonexistent22EXPECTED_OUTPUT='Alias does not exist.'23[ "_$CAPTURED_STDERR" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias nonexistent' produced wrong output; got $CAPTURED_STDERR"24[ "_$CAPTURED_EXIT_CODE" = "_2" ] || die "'nvm_alias nonexistent' exited with $CAPTURED_EXIT_CODE, expected 2"2526EXPECTED_OUTPUT="0.10"27nvm alias test "$EXPECTED_OUTPUT" || die "'nvm alias test $EXPECTED_OUTPUT' failed"28OUTPUT="$(nvm_alias test)"29[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_alias test' produced wrong output; got $OUTPUT"3031cleanup