From b89fd89a5bbc934503eb92bd69af93b237b41691 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 27 Dec 2022 22:57:07 -0800 Subject: [PATCH] [Tests] add some `nvm_do_install` tests --- test/install_script/nvm_do_install | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/install_script/nvm_do_install b/test/install_script/nvm_do_install index 5fb0d272abf..8d7e8bbcf50 100755 --- a/test/install_script/nvm_do_install +++ b/test/install_script/nvm_do_install @@ -6,3 +6,11 @@ NVM_ENV=testing \. ../../install.sh #nvm_do_install is available type nvm_do_install > /dev/null 2>&1 || die 'nvm_do_install is not available' + +FILE_PATH="$(pwd)/nvm_do_install" +EXIT_CODE=$(NVM_DIR="${FILE_PATH}" nvm_do_install; echo $?) +[ $EXIT_CODE -eq 1 ] || die 'nvm_do_install should fail if NVM_DIR is a file' + +ACTUAL="$(NVM_DIR="${FILE_PATH}" nvm_do_install)" +EXPECTED="File \"${FILE_PATH}\" has the same name as installation directory." +[ "${ACTUAL}" = "${EXPECTED}" ] || die 'nvm_do_install should fail if NVM_DIR is a file'