Skip to content
Myr

nvm_install_binary_nosource

This file

Path

test/fast/Unit tests/nvm_install_binary_nosource

34 lines · 1.1 KiB

Last changed by

[Tests] fix 4 test failuresJordan Harbandbefore adoption3e37cfb

History of this file

Take it

1#!/bin/sh23cleanup () {4  nvm cache clear5  nvm deactivate6  rm -rf ${NVM_DIR}/v*7  nvm unalias default8}910die () { echo "$@" ; cleanup; exit 1;}1112: nvm.sh13\. ../../../nvm.sh1415nvm_binary_available() {16    return 117}1819# Unit test to check if the function errors out when the flag is set20OUTPUT="$(nvm_install_binary node std 8.0.0 1 2>&1)"21EXPECTED_OUTPUT='Binary download failed. Download from source aborted.'22if [ "${OUTPUT#*$EXPECTED_OUTPUT}" = "${OUTPUT}" ]; then23  die "No source binary flag is active and should have returned >${EXPECTED_OUTPUT}<. Instead it returned >${OUTPUT}<"24fi2526nvm_install_binary node std 8.0.0 1 >/dev/null 2>&1; EXIT_CODE=$?27[ "${EXIT_CODE}" = "2" ] || die "Expected exit code 2 when nosource=1 and binary fails, got ${EXIT_CODE}"2829# Unit test to check if the function errors out when the flag is set30OUTPUT="$(nvm_install_binary node std 8.0.0 0 2>&1)"31EXPECTED_OUTPUT='Binary download failed. Download from source aborted.'32if [ "${OUTPUT#*$EXPECTED_OUTPUT}" != "${OUTPUT}" ]; then33  die "No source binary flag is not active and should have downloaded from source. Instead it returned >${OUTPUT}<"34fi