Write test for the exec-path functionality in the which command

This commit is contained in:
Trevor Brown 2019-01-05 10:54:02 -05:00
parent c37307a2cc
commit 8bcf8caba4
2 changed files with 20 additions and 0 deletions

View File

@ -35,6 +35,17 @@ install_dummy_version() {
install_mock_plugin_version "dummy" "$1"
}
install_dummy_exec_path_script() {
local name=$1
local exec_path="$ASDF_DIR/plugins/dummy/bin/exec-path"
local custom_dir="$ASDF_DIR/installs/dummy/1.0/bin/custom"
mkdir "$custom_dir"
touch "$custom_dir/$name"
chmod +x "$custom_dir/$name"
echo "echo 'bin/custom'" > "$exec_path"
chmod +x "$exec_path"
}
clean_asdf_dir() {
rm -rf "$BASE_DIR"
unset ASDF_DIR

View File

@ -51,3 +51,12 @@ teardown() {
[ "$status" -eq 1 ]
[ "$output" = "No executable binary found for bazbat" ]
}
@test "which should use path returned by exec-path when present" {
cd $PROJECT_DIR
install_dummy_exec_path_script "dummy"
run which_command "dummy"
[ "$status" -eq 0 ]
[ "$output" = "$ASDF_DIR/installs/dummy/1.0/bin/custom/dummy" ]
}