2017-08-24 19:29:23 -07:00
|
|
|
#!/usr/bin/env bats
|
2023-01-27 05:17:41 -07:00
|
|
|
# shellcheck disable=SC2030,SC2031
|
2017-08-24 19:29:23 -07:00
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
setup_asdf_dir
|
|
|
|
setup_repo
|
2018-10-27 12:05:02 -07:00
|
|
|
install_dummy_plugin
|
2017-08-24 19:29:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
clean_asdf_dir
|
|
|
|
}
|
|
|
|
|
2022-06-27 16:47:49 -07:00
|
|
|
@test "plugin_list_all should exit before syncing the plugin repo if disabled" {
|
2023-01-22 16:36:47 -07:00
|
|
|
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
|
|
|
|
echo 'disable_plugin_short_name_repository=yes' >"$ASDF_CONFIG_DEFAULT_FILE"
|
2022-06-27 16:47:49 -07:00
|
|
|
local expected="Short-name plugin repository is disabled"
|
|
|
|
|
|
|
|
run asdf plugin list all
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
[ "$output" = "$expected" ]
|
|
|
|
}
|
|
|
|
|
2021-06-01 21:22:27 -07:00
|
|
|
@test "plugin_list_all should sync repo when check_duration set to 0" {
|
2023-01-22 16:36:47 -07:00
|
|
|
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
|
|
|
|
echo 'plugin_repository_last_check_duration = 0' >"$ASDF_CONFIG_DEFAULT_FILE"
|
2021-06-01 21:22:27 -07:00
|
|
|
local expected_plugin_repo_sync="updating plugin repository..."
|
|
|
|
local expected_plugins_list="\
|
|
|
|
bar http://example.com/bar
|
|
|
|
dummy *http://example.com/dummy
|
|
|
|
foo http://example.com/foo"
|
|
|
|
|
2022-06-27 16:47:49 -07:00
|
|
|
run asdf plugin list all
|
2021-06-01 21:22:27 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2023-01-25 06:37:21 -07:00
|
|
|
[[ "$output" == *"$expected_plugin_repo_sync"* ]]
|
|
|
|
[[ "$output" == *"$expected_plugins_list"* ]]
|
2021-06-01 21:22:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "plugin_list_all no immediate repo sync expected because check_duration is greater than 0" {
|
2023-01-22 16:36:47 -07:00
|
|
|
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
|
|
|
|
echo 'plugin_repository_last_check_duration = 10' >"$ASDF_CONFIG_DEFAULT_FILE"
|
2021-06-01 21:22:27 -07:00
|
|
|
local expected="\
|
|
|
|
bar http://example.com/bar
|
|
|
|
dummy *http://example.com/dummy
|
|
|
|
foo http://example.com/foo"
|
|
|
|
|
2022-06-27 16:47:49 -07:00
|
|
|
run asdf plugin list all
|
2021-06-01 21:22:27 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$expected" ]
|
|
|
|
}
|
|
|
|
|
2021-08-03 15:41:19 -07:00
|
|
|
@test "plugin_list_all skips repo sync because check_duration is set to never" {
|
2023-01-22 16:36:47 -07:00
|
|
|
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
|
|
|
|
echo 'plugin_repository_last_check_duration = never' >"$ASDF_CONFIG_DEFAULT_FILE"
|
2021-08-03 15:41:19 -07:00
|
|
|
local expected="\
|
|
|
|
bar http://example.com/bar
|
|
|
|
dummy *http://example.com/dummy
|
|
|
|
foo http://example.com/foo"
|
|
|
|
|
2022-06-27 16:47:49 -07:00
|
|
|
run asdf plugin list all
|
2021-08-03 15:41:19 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$expected" ]
|
|
|
|
}
|
|
|
|
|
2017-08-24 19:29:23 -07:00
|
|
|
@test "plugin_list_all list all plugins in the repository" {
|
2019-11-30 13:08:52 -07:00
|
|
|
local expected="\
|
2020-06-16 15:26:46 -07:00
|
|
|
bar http://example.com/bar
|
|
|
|
dummy *http://example.com/dummy
|
|
|
|
foo http://example.com/foo"
|
2021-08-03 15:41:19 -07:00
|
|
|
|
2022-06-27 16:47:49 -07:00
|
|
|
run asdf plugin list all
|
2017-08-24 19:29:23 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$expected" ]
|
|
|
|
}
|