From 97d4e2f88f4642006671fe446a65d9ddf0cd0d32 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 15 Sep 2014 09:09:56 -0700 Subject: [PATCH] Unit tests: add `nvm_find_up` --- test/fast/Unit tests/nvm_find_up | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 test/fast/Unit tests/nvm_find_up diff --git a/test/fast/Unit tests/nvm_find_up b/test/fast/Unit tests/nvm_find_up new file mode 100755 index 0000000..39fb568 --- /dev/null +++ b/test/fast/Unit tests/nvm_find_up @@ -0,0 +1,26 @@ +#!/bin/sh + +die () { echo $@ ; cleanup ; exit 1; } +setup() { + cleanup + mkdir -p tmp_nvm_find_up/a/b/c/d + touch tmp_nvm_find_up/test + touch tmp_nvm_find_up/a/b/c/test +} +cleanup () { + rm -rf tmp_nvm_find_up +} + +. ../../../nvm.sh + +setup + +TEST_DIR="$PWD" + +[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up" ] || die "failed to find 1 dir up" +[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up" ] || die "failed to find 2 dirs up" +[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b/c nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up/a/b/c" ] || die "failed to find in current dir" +[ "~$(PWD=$TEST_DIR/tmp_nvm_find_up/a/b/c/d nvm_find_up 'test')" = "~$TEST_DIR/tmp_nvm_find_up/a/b/c" ] || die "failed to find 1 level up from current dir" + +cleanup +