mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 09:38:16 -07:00
Merge pull request #379 from asdf-vm/tb/plugin-test-fixes
plugin-test fixes
This commit is contained in:
commit
d5ded35c33
@ -8,25 +8,26 @@ plugin_test_command() {
|
||||
local exit_code
|
||||
local TEST_DIR
|
||||
|
||||
TEST_DIR=$(mktemp -dt asdf.XXXX)
|
||||
git clone "$ASDF_DIR/.git" "$TEST_DIR"
|
||||
|
||||
fail_test() {
|
||||
echo "FAILED: $1"
|
||||
rm -rf "$TEST_DIR"
|
||||
exit 1
|
||||
}
|
||||
|
||||
plugin_test() {
|
||||
export ASDF_DIR=$TEST_DIR
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
source "$ASDF_DIR/asdf.sh"
|
||||
|
||||
if [ -z "$plugin_name" ] || [ -z "$plugin_url" ]; then
|
||||
fail_test "please provide a plugin name and url"
|
||||
fi
|
||||
|
||||
TEST_DIR=$(mktemp -dt asdf.XXXX)
|
||||
git clone "$ASDF_DIR/.git" "$TEST_DIR"
|
||||
|
||||
plugin_test() {
|
||||
export ASDF_DIR=$TEST_DIR
|
||||
export ASDF_DATA_DIR=$TEST_DIR
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
source "$ASDF_DIR/asdf.sh"
|
||||
|
||||
if ! (asdf plugin-add "$plugin_name" "$plugin_url"); then
|
||||
fail_test "could not install $plugin_name from $plugin_url"
|
||||
fi
|
||||
|
27
test/plugin_test_command.bats
Normal file
27
test/plugin_test_command.bats
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helpers
|
||||
|
||||
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/plugin-add.sh
|
||||
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/plugin-list.sh
|
||||
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/plugin-test.sh
|
||||
|
||||
setup() {
|
||||
setup_asdf_dir
|
||||
}
|
||||
|
||||
teardown() {
|
||||
clean_asdf_dir
|
||||
}
|
||||
|
||||
@test "plugin_test_command with no URL specified prints an error" {
|
||||
run plugin_test_command "elixir"
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "FAILED: please provide a plugin name and url" ]
|
||||
}
|
||||
|
||||
@test "plugin_test_command with no name or URL specified prints an error" {
|
||||
run plugin_test_command
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "FAILED: please provide a plugin name and url" ]
|
||||
}
|
Loading…
Reference in New Issue
Block a user