Skip to content
Myr

nvm_print_alias_path

This file

Path

test/fast/Unit tests/nvm_print_alias_path

44 lines · 1.5 KiB

Last changed by

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

History of this file

Take it

The walk stopped after 200 commits: lines older than 14507f8 point at it.

[Tests] migrate `installation_iojs` test suite to GitHub ActionsJessica Wagantallbefore adoption14507f8

lines 1–9why, one step back
1#!/bin/sh
2\. ../../common.sh34die () { echo "$@" ; cleanup ; exit 1; }56cleanup () {7 unset -f nvm_alias nvm_version8}9

[Tests] set `$_` before sourcing `nvm.sh` in fast testsJordan Harbandbefore adoptionc451e7a

line 10why, one step back
10: nvm.sh

[Tests] migrate `installation_iojs` test suite to GitHub ActionsJessica Wagantallbefore adoption14507f8

lines 11–26why, one step back
11\. ../../../nvm.sh
1213NVM_ALIAS_DIR='path/to/the alias/dir'1415OUTPUT="$(nvm_print_alias_path 2>&1)"16EXPECTED_OUTPUT='An alias dir is required.'17[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "'nvm_print_alias_path' produced wrong output; got '$OUTPUT', expected '$EXPECTED_OUTPUT'"1819OUTPUT="$(nvm_print_alias_path "$NVM_ALIAS_DIR" 2>&1)"20EXPECTED_OUTPUT='An alias path is required.'21[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "'nvm_print_alias_path \"\$NVM_ALIAS_DIR\"' produced wrong output; got '$OUTPUT', expected '$EXPECTED_OUTPUT'"2223nvm_alias() {24 echo ''25}26

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

lines 27–28why, one step back
27try nvm_print_alias_path "$NVM_ALIAS_DIR" foo
28OUTPUT="$(echo "$CAPTURED_STDOUT" | strip_colors)"

[Tests] migrate `installation_iojs` test suite to GitHub ActionsJessica Wagantallbefore adoption14507f8

lines 29–30why, one step back
29EXPECTED_OUTPUT=''
30[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_print_alias_path \"\$NVM_ALIAS_DIR\" foo' should produce no output when nvm_alias does not; got '$OUTPUT'"

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

line 31why, one step back
31[ "$CAPTURED_EXIT_CODE" = '0' ] || die "'nvm_print_alias_path \"\$NVM_ALIAS_DIR\" foo' should exit zero when nvm_alias produces no output; got $CAPTURED_EXIT_CODE"

[Tests] migrate `installation_iojs` test suite to GitHub ActionsJessica Wagantallbefore adoption14507f8

lines 32–40why, one step back
32
33nvm_alias() {34 echo "\"$1\""35}36nvm_version() {37 echo "v$1"38}3940OUTPUT="$(nvm_print_alias_path "$NVM_ALIAS_DIR" "$NVM_ALIAS_DIR/blah" | strip_colors)"

[Fix] `nvm_has_colors`: also check if stdout is a terminalJordan Harbandbefore adoption35212c1

line 41why, one step back
41EXPECTED_OUTPUT='blah -> "blah" (-> v"blah" *)'

[Tests] migrate `installation_iojs` test suite to GitHub ActionsJessica Wagantallbefore adoption14507f8

lines 42–44why, one step back
42[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "'nvm_print_alias_path \"\$NVM_ALIAS_DIR\" \"\$NVM_ALIAS_DIR/blah\"' should strip alias dir and print nvm_alias output; got '$OUTPUT', expected '$EXPECTED_OUTPUT'"
4344cleanup