Skip to content
Myr

nvm_print_default_alias

This file

Path

test/fast/Unit tests/nvm_print_default_alias

38 lines · 1.2 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 5c12680 point at it.

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

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

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

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

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 11–20why, one step back
11\. ../../../nvm.sh
1213nvm_print_implicit_alias() {14 echo ''15}1617OUTPUT="$(nvm_print_default_alias 2>&1)"18EXPECTED_OUTPUT='A default alias is required.'19[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "'nvm_print_default_alias' produced wrong output; got '$OUTPUT', expected '$EXPECTED_OUTPUT'"20

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

lines 21–22why, one step back
21try nvm_print_default_alias foo
22OUTPUT="$(echo "$CAPTURED_STDOUT" | strip_colors)"

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 23–24why, one step back
23EXPECTED_OUTPUT=''
24[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'nvm_print_default_alias foo' should produce no output when nvm_print_implicit_alias does not; got '$OUTPUT'"

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

line 25why, one step back
25[ "$CAPTURED_EXIT_CODE" = '0' ] || die "'nvm_print_default_alias foo' should exit zero when nvm_print_implicit_alias produces no output; got $CAPTURED_EXIT_CODE"

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 26–34why, one step back
26
27nvm_print_implicit_alias() {28 echo "\"$1-$2\""29}30nvm_version() {31 echo "v$1"32}3334OUTPUT="$(nvm_print_default_alias blah | strip_colors)"

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

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

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 36–38why, one step back
36[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "'nvm_print_default_alias blah' should strip alias dir and print nvm_print_implicit_alias output; got '$OUTPUT', expected '$EXPECTED_OUTPUT'"
3738cleanup