Skip to content
Myr

nvm_remote_version: add unit tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

`nvm_ls_remote` is stubbed out to avoid making network calls here.

authored by Jordan Harband · committed by Jordan Harband · parent ff92ba7 · Browse files · 1 file+35 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+35 added−0 removed

  • tests:+35 added−0 removed

1 file+35 added−0 removed

added:test/fast/Unit tests/nvm_remote_version+35 added
1#!/bin/sh23die () { echo $@ ; cleanup ; exit 1; }45cleanup() {6 unset -f nvm_ls_remote7}89. ../../../nvm.sh1011nvm_ls_remote() {12 echo "N/A"13}1415OUTPUT="$(nvm_remote_version foo)"16EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"1718[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A"19[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE"2021nvm_ls_remote() {22 echo "test output"23 echo "more test output"24 echo "pattern received: _$1_"25}2627OUTPUT="$(nvm_remote_version foo)"28EXIT_CODE="$(nvm_remote_version foo >/dev/null 2>&1 ; echo $?)"2930[ "_$OUTPUT" = "_pattern received: _foo_" ] \31 || die "nvm_remote_version foo did not return last line only of nvm_ls_remote foo; got $OUTPUT"32[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_version foo did not exit with 0, got $EXIT_CODE"3334cleanup35