asdf/test/which_command.bats
Melissa Xie f79dda865a Include plugin name in error message if plugin doesn't exist
Previously, if we ran a command like `asdf install` and we encountered a
plugin that didn't exist, asdf produces an error saying "No such
plugin". Without knowing which plugin it could be referring too, we'd
have to manually go through each plugin in `.tool-versions` to find the
culprit.

With this commit, we'll now also include the plugin name as part of the
messaging for easier debugging.
2018-04-30 12:49:40 -04:00

48 lines
1010 B
Bash

#!/usr/bin/env bats
load test_helpers
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/which.sh
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/install.sh
setup() {
setup_asdf_dir
install_dummy_plugin
install_mock_plugin "bazbat"
run install_command dummy 1.0
PROJECT_DIR=$HOME/project
mkdir $PROJECT_DIR
}
teardown() {
clean_asdf_dir
}
@test "which should show dummy 1.0 main binary path" {
cd $PROJECT_DIR
echo 'dummy 1.0' >> $PROJECT_DIR/.tool-versions
run which_command "dummy"
[ "$status" -eq 0 ]
[ "$output" = "$ASDF_DIR/installs/dummy/1.0/bin/dummy" ]
}
@test "which should inform when no version is set" {
cd $PROJECT_DIR
local expected
expected="No version set for bazbat; please run \`asdf <global | local> bazbat <version>\`"
run which_command "bazbat"
[ "$status" -eq 1 ]
[ "$output" = "$expected" ]
}
@test "which should error when the plugin doesn't exist" {
run which_command "foobar"
[ "$status" -eq 1 ]
[ "$output" = "No such plugin: foobar" ]
}