14
@test "plugin_add command with plugin name matching all valid regex chars succeeds" {
15
install_mock_plugin_repo "plugin_with-all-valid-chars-123"
17
run asdf plugin add "plugin_with-all-valid-chars-123" "${BASE_DIR}/repo-plugin_with-all-valid-chars-123"
21
[ "$output" = "plugin_with-all-valid-chars-123" ]
24
@test "plugin_add command with LANG=sv_SE.UTF-8 and plugin name matching all valid regex chars succeeds" {
28
install_mock_plugin_repo "plugin-with-w"
32
run asdf plugin add "plugin-with-w" "${BASE_DIR}/repo-plugin-with-w"
36
[ "$output" = "plugin-with-w" ]
41
@test "plugin_add command with plugin name not matching valid regex fails 1" {
42
run asdf plugin add "invalid\$plugin\$name"
44
[ "$output" = "invalid\$plugin\$name is invalid. Name may only contain lowercase letters, numbers, '_', and '-'" ]
47
@test "plugin_add command with plugin name not matching valid regex fails 2" {
48
run asdf plugin add "#invalid#plugin#name"
50
[ "$output" = "#invalid#plugin#name is invalid. Name may only contain lowercase letters, numbers, '_', and '-'" ]
53
@test "plugin_add command with plugin name not matching valid regex fails 3" {
54
run asdf plugin add "Ruby"
56
[ "$output" = "Ruby is invalid. Name may only contain lowercase letters, numbers, '_', and '-'" ]
59
@test "plugin_add command with no URL specified adds a plugin using repo" {
60
run asdf plugin add "elixir"
64
[ "$output" = "elixir" ]
67
@test "plugin_add command with no URL specified adds a plugin when short name repository is enabled" {
68
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
69
echo "disable_plugin_short_name_repository=no" >"$ASDF_CONFIG_DEFAULT_FILE"
71
run asdf plugin add "elixir"
74
local expected="elixir"
76
[ "$output" = "$expected" ]
79
@test "plugin_add command with no URL specified fails to add a plugin when disabled" {
80
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
81
echo "disable_plugin_short_name_repository=yes" >"$ASDF_CONFIG_DEFAULT_FILE"
82
local expected="Short-name plugin repository is disabled"
84
run asdf plugin add "elixir"
86
[ "$output" = "$expected" ]
89
@test "plugin_add command with URL specified adds a plugin using repo" {
90
install_mock_plugin_repo "dummy"
92
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
97
[ "$output" = "dummy" ]
100
@test "plugin_add command with URL specified twice returns success on second time" {
101
install_mock_plugin_repo "dummy"
103
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
104
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
106
[ "$output" = "Plugin named dummy already added" ]
109
@test "plugin_add command with no URL specified fails if the plugin doesn't exist" {
110
run asdf plugin add "does-not-exist"
112
echo "$output" | grep "plugin does-not-exist not found in repository"
115
@test "plugin_add command executes post-plugin add script" {
116
install_mock_plugin_repo "dummy"
118
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
119
[ "$output" = "plugin add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy" ]
122
@test "plugin_add command executes configured pre hook (generic)" {
123
install_mock_plugin_repo "dummy"
125
cat >"$HOME/.asdfrc" <<-'EOM'
126
pre_asdf_plugin_add = echo ADD ${@}
129
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
131
local expected_output="ADD dummy
132
plugin add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy"
133
[ "$output" = "${expected_output}" ]
136
@test "plugin_add command executes configured pre hook (specific)" {
137
install_mock_plugin_repo "dummy"
139
cat >"$HOME/.asdfrc" <<-'EOM'
140
pre_asdf_plugin_add_dummy = echo ADD
143
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
145
local expected_output="ADD
146
plugin add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy"
147
[ "$output" = "${expected_output}" ]
150
@test "plugin_add command executes configured post hook (generic)" {
151
install_mock_plugin_repo "dummy"
153
cat >"$HOME/.asdfrc" <<-'EOM'
154
post_asdf_plugin_add = echo ADD ${@}
157
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
159
local expected_output="plugin add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy
161
[ "$output" = "${expected_output}" ]
164
@test "plugin_add command executes configured post hook (specific)" {
165
install_mock_plugin_repo "dummy"
167
cat >"$HOME/.asdfrc" <<-'EOM'
168
post_asdf_plugin_add_dummy = echo ADD
171
run asdf plugin add "dummy" "${BASE_DIR}/repo-dummy"
173
local expected_output="plugin add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy
175
[ "$output" = "${expected_output}" ]