Browse Source

[Tests] Add unit test for nvm_download

nmarghetti 4 years ago committed by Jordan Harband
parent
commit
60e78d3ec1
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
  1. 18
      test/fast/Unit tests/nvm_download
  2. 18
      test/install_script/nvm_download

18
test/fast/Unit tests/nvm_download

@ -0,0 +1,18 @@
#!/bin/sh
cleanup () {
unset -f die cleanup
}
die () { echo "$@" ; cleanup ; exit 1; }
\. ../../../nvm.sh
set -ex
# nvm_download install.sh
nvm_download "https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh" >/dev/null || die "nvm_download unable to download install.sh"
# nvm_download should fail to download wrong_install.sh
! nvm_download "https://raw.githubusercontent.com/nvm-sh/nvm/master/wrong_install.sh" >/dev/null || die "nvm_download should fail to download no existing file"
cleanup

18
test/install_script/nvm_download

@ -0,0 +1,18 @@
#!/bin/sh
cleanup () {
unset -f die cleanup
}
die () { echo "$@" ; cleanup ; exit 1; }
NVM_ENV=testing \. ../../install.sh
# nvm_download install.sh
nvm_download "https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh" >/dev/null || die "nvm_download unable to download install.sh"
# nvm_download should fail to download wrong_install.sh
if nvm_download "https://raw.githubusercontent.com/nvm-sh/nvm/master/wrong_install.sh" &>/dev/null; then
die "nvm_download should fail to download no existing file"
fi
cleanup
Loading…
Cancel
Save