2017-07-23 09:34:58 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
setup_asdf_dir
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
clean_asdf_dir
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_add command with no URL specified adds a plugin using repo" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf plugin-add "elixir"
|
2017-07-23 09:34:58 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf plugin-list
|
2018-01-13 21:50:49 -07:00
|
|
|
# whitespace between 'elixir' and url is from printf %-15s %s format
|
2018-01-14 01:38:00 -07:00
|
|
|
[ "$output" = "elixir" ]
|
2017-07-23 09:34:58 -07:00
|
|
|
}
|
2017-07-25 17:03:30 -07:00
|
|
|
|
2020-03-21 06:59:33 -07:00
|
|
|
@test "plugin_add command with URL specified adds a plugin using repo" {
|
|
|
|
install_mock_plugin_repo "dummy"
|
|
|
|
|
|
|
|
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
run asdf plugin-list
|
|
|
|
# whitespace between 'elixir' and url is from printf %-15s %s format
|
|
|
|
[ "$output" = "dummy" ]
|
|
|
|
}
|
|
|
|
|
2020-03-31 06:20:10 -07:00
|
|
|
@test "plugin_add command with URL specified run twice returns error second time" {
|
|
|
|
install_mock_plugin_repo "dummy"
|
|
|
|
|
|
|
|
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
|
|
|
|
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
|
|
|
|
[ "$status" -eq 2 ]
|
|
|
|
[ "$output" = "Plugin named dummy already added" ]
|
|
|
|
}
|
|
|
|
|
2017-07-25 17:03:30 -07:00
|
|
|
@test "plugin_add command with no URL specified fails if the plugin doesn't exist" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf plugin-add "does-not-exist"
|
2017-07-25 17:03:30 -07:00
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
echo "$output" | grep "plugin does-not-exist not found in repository"
|
|
|
|
}
|
2020-03-21 06:59:33 -07:00
|
|
|
|
2020-03-21 18:57:54 -07:00
|
|
|
@test "plugin_add command executes post-plugin-add script" {
|
|
|
|
install_mock_plugin_repo "dummy"
|
|
|
|
|
|
|
|
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
|
|
|
|
|
|
|
|
[ "$output" = "plugin-add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy" ]
|
|
|
|
}
|
|
|
|
|
2020-03-21 06:59:33 -07:00
|
|
|
@test "plugin_add command executes configured pre hook (generic)" {
|
|
|
|
install_mock_plugin_repo "dummy"
|
|
|
|
|
|
|
|
cat > $HOME/.asdfrc <<-'EOM'
|
|
|
|
pre_asdf_plugin_add = echo ADD ${@}
|
|
|
|
EOM
|
|
|
|
|
|
|
|
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
|
|
|
|
|
|
|
|
local expected_output="ADD dummy
|
|
|
|
plugin-add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy"
|
|
|
|
[ "$output" = "${expected_output}" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_add command executes configured pre hook (specific)" {
|
|
|
|
install_mock_plugin_repo "dummy"
|
|
|
|
|
|
|
|
cat > $HOME/.asdfrc <<-'EOM'
|
|
|
|
pre_asdf_plugin_add_dummy = echo ADD
|
|
|
|
EOM
|
|
|
|
|
|
|
|
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
|
|
|
|
|
|
|
|
local expected_output="ADD
|
|
|
|
plugin-add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy"
|
|
|
|
[ "$output" = "${expected_output}" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_add command executes configured post hook (generic)" {
|
|
|
|
install_mock_plugin_repo "dummy"
|
|
|
|
|
|
|
|
cat > $HOME/.asdfrc <<-'EOM'
|
|
|
|
post_asdf_plugin_add = echo ADD ${@}
|
|
|
|
EOM
|
|
|
|
|
|
|
|
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
|
|
|
|
|
|
|
|
local expected_output="plugin-add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy
|
|
|
|
ADD dummy"
|
|
|
|
[ "$output" = "${expected_output}" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_add command executes configured post hook (specific)" {
|
|
|
|
install_mock_plugin_repo "dummy"
|
|
|
|
|
|
|
|
cat > $HOME/.asdfrc <<-'EOM'
|
|
|
|
post_asdf_plugin_add_dummy = echo ADD
|
|
|
|
EOM
|
|
|
|
|
|
|
|
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
|
|
|
|
|
|
|
|
local expected_output="plugin-add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy
|
|
|
|
ADD"
|
|
|
|
[ "$output" = "${expected_output}" ]
|
|
|
|
}
|