2016-07-05 16:19:15 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
setup_asdf_dir
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
clean_asdf_dir
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_remove_command removes a plugin" {
|
|
|
|
install_dummy_plugin
|
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf plugin-remove "dummy"
|
2016-07-05 16:19:15 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2020-03-21 06:59:33 -07:00
|
|
|
[ "$output" = "plugin-remove ${ASDF_DIR}/plugins/dummy" ]
|
2016-07-05 16:19:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_remove_command should exit with 1 when not passed any arguments" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf plugin-remove
|
2016-07-05 16:19:15 -07:00
|
|
|
[ "$status" -eq 1 ]
|
2017-03-25 12:16:58 -07:00
|
|
|
[ "$output" = "No plugin given" ]
|
2016-07-05 16:19:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_remove_command should exit with 1 when passed invalid plugin name" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf plugin-remove "does-not-exist"
|
2016-07-05 16:19:15 -07:00
|
|
|
[ "$status" -eq 1 ]
|
2018-04-30 09:49:40 -07:00
|
|
|
[ "$output" = "No such plugin: does-not-exist" ]
|
2016-07-05 16:19:15 -07:00
|
|
|
}
|
2016-12-10 12:54:22 -07:00
|
|
|
|
|
|
|
@test "plugin_remove_command should remove installed versions" {
|
|
|
|
install_dummy_plugin
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
2016-12-10 12:54:22 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2023-01-22 05:04:46 -07:00
|
|
|
[ -d "$ASDF_DIR/installs/dummy" ]
|
2016-12-10 12:54:22 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf plugin-remove dummy
|
2016-12-10 12:54:22 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2023-01-22 05:04:46 -07:00
|
|
|
[ ! -d "$ASDF_DIR/installs/dummy" ]
|
2016-12-10 12:54:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_remove_command should also remove shims for that plugin" {
|
|
|
|
install_dummy_plugin
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
2016-12-10 12:54:22 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2023-01-22 05:04:46 -07:00
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
2016-12-10 12:54:22 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf plugin-remove dummy
|
2016-12-10 12:54:22 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2023-01-22 05:04:46 -07:00
|
|
|
[ ! -f "$ASDF_DIR/shims/dummy" ]
|
2016-12-10 12:54:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_remove_command should not remove unrelated shims" {
|
|
|
|
install_dummy_plugin
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
2016-12-10 12:54:22 -07:00
|
|
|
|
|
|
|
# make an unrelated shim
|
2023-01-22 02:20:23 -07:00
|
|
|
echo "# asdf-plugin: gummy" >"$ASDF_DIR/shims/gummy"
|
2016-12-10 12:54:22 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf plugin-remove dummy
|
2016-12-10 12:54:22 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
# unrelated shim should exist
|
2023-01-22 05:04:46 -07:00
|
|
|
[ -f "$ASDF_DIR/shims/gummy" ]
|
2017-03-25 12:16:58 -07:00
|
|
|
}
|
2020-03-21 06:59:33 -07:00
|
|
|
|
2020-03-21 18:57:54 -07:00
|
|
|
@test "plugin_remove_command executes pre-plugin-remove script" {
|
|
|
|
install_dummy_plugin
|
|
|
|
|
|
|
|
run asdf plugin-remove dummy
|
|
|
|
|
|
|
|
[ "$output" = "plugin-remove ${ASDF_DIR}/plugins/dummy" ]
|
|
|
|
}
|
|
|
|
|
2020-03-21 06:59:33 -07:00
|
|
|
@test "plugin_remove_command executes configured pre hook (generic)" {
|
|
|
|
install_dummy_plugin
|
|
|
|
|
2023-01-22 21:29:18 -07:00
|
|
|
cat >"$HOME/.asdfrc" <<-'EOM'
|
2020-03-21 06:59:33 -07:00
|
|
|
pre_asdf_plugin_remove = echo REMOVE ${@}
|
|
|
|
EOM
|
|
|
|
|
|
|
|
run asdf plugin-remove dummy
|
|
|
|
|
|
|
|
local expected_output="REMOVE dummy
|
|
|
|
plugin-remove ${ASDF_DIR}/plugins/dummy"
|
|
|
|
[ "$output" = "${expected_output}" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_remove_command executes configured pre hook (specific)" {
|
|
|
|
install_dummy_plugin
|
|
|
|
|
2023-01-22 21:29:18 -07:00
|
|
|
cat >"$HOME/.asdfrc" <<-'EOM'
|
2020-03-21 06:59:33 -07:00
|
|
|
pre_asdf_plugin_remove_dummy = echo REMOVE
|
|
|
|
EOM
|
|
|
|
|
|
|
|
run asdf plugin-remove dummy
|
|
|
|
|
|
|
|
local expected_output="REMOVE
|
|
|
|
plugin-remove ${ASDF_DIR}/plugins/dummy"
|
|
|
|
[ "$output" = "${expected_output}" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_remove_command executes configured post hook (generic)" {
|
|
|
|
install_dummy_plugin
|
|
|
|
|
2023-01-22 21:29:18 -07:00
|
|
|
cat >"$HOME/.asdfrc" <<-'EOM'
|
2020-03-21 06:59:33 -07:00
|
|
|
post_asdf_plugin_remove = echo REMOVE ${@}
|
|
|
|
EOM
|
|
|
|
|
|
|
|
run asdf plugin-remove dummy
|
|
|
|
|
|
|
|
local expected_output="plugin-remove ${ASDF_DIR}/plugins/dummy
|
|
|
|
REMOVE dummy"
|
|
|
|
[ "$output" = "${expected_output}" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_remove_command executes configured post hook (specific)" {
|
|
|
|
install_dummy_plugin
|
|
|
|
|
2023-01-22 21:29:18 -07:00
|
|
|
cat >"$HOME/.asdfrc" <<-'EOM'
|
2020-03-21 06:59:33 -07:00
|
|
|
post_asdf_plugin_remove_dummy = echo REMOVE
|
|
|
|
EOM
|
|
|
|
|
|
|
|
run asdf plugin-remove dummy
|
|
|
|
|
|
|
|
local expected_output="plugin-remove ${ASDF_DIR}/plugins/dummy
|
|
|
|
REMOVE"
|
|
|
|
[ "$output" = "${expected_output}" ]
|
|
|
|
}
|