nvm_install_profile_skip
This file
Path
test/install_script/nvm_install_profile_skip
62 lines · 1.6 KiB
Last changed by
[Fix] `install.sh`: do not log when user has requested no profile modificationsWes Toddbefore adoptionec8906b
History of this fileTake it
1#!/bin/sh23die () { echo "$@" ; cleanup ; exit 1; }45cleanup() {6 unset -f install_nvm_from_git install_nvm_as_script nvm_detect_profile nvm_has7 unset -f setup cleanup die8 unset NVM_ENV METHOD PROFILE9}1011setup() {12 NVM_ENV=testing \. ../../install.sh1314 # Mock installation functions to do nothing15 install_nvm_from_git() { :; }16 install_nvm_as_script() { :; }1718 # Mock nvm_has to return true for git (to take the git path)19 nvm_has() {20 case "$1" in21 git) return 0 ;;22 xcode-select) return 1 ;;23 *) return 1 ;;24 esac25 }2627 # Mock nvm_detect_profile to return empty (no profile found)28 nvm_detect_profile() {29 echo ""30 }31}3233setup3435#36# Test: When PROFILE="/dev/null", no "Profile not found" warning should appear37#3839OUTPUT="$(PROFILE='/dev/null' METHOD='' NVM_DIR="$(mktemp -d)" nvm_do_install 2>&1)"40if echo "$OUTPUT" | grep -q "Profile not found"; then41 die "nvm_do_install should NOT show 'Profile not found' when PROFILE=/dev/null, got: $OUTPUT"42fi4344#45# Test: When PROFILE is empty/unset, the "Profile not found" warning SHOULD appear46#4748OUTPUT="$(PROFILE='' METHOD='' NVM_DIR="$(mktemp -d)" nvm_do_install 2>&1)"49if ! echo "$OUTPUT" | grep -q "Profile not found"; then50 die "nvm_do_install should show 'Profile not found' when PROFILE is empty, got: $OUTPUT"51fi5253#54# Test: When PROFILE points to a non-existent file, the "Profile not found" warning SHOULD appear55#5657OUTPUT="$(PROFILE='/nonexistent/profile' METHOD='' NVM_DIR="$(mktemp -d)" nvm_do_install 2>&1)"58if ! echo "$OUTPUT" | grep -q "Profile not found"; then59 die "nvm_do_install should show 'Profile not found' when PROFILE points to nonexistent file, got: $OUTPUT"60fi6162cleanup