mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-12-25 12:55:09 -07:00
e7df5ff325
* Enable `plugin_list_all_command.bats` tests * Create `PluginIndex.Get` method * Create `asdf plugin list all` subcommand * Extract plugin index repo URL into config package * Fix failing tests
75 lines
2.3 KiB
Bash
75 lines
2.3 KiB
Bash
#!/usr/bin/env bats
|
|
# shellcheck disable=SC2030,SC2031
|
|
|
|
load test_helpers
|
|
|
|
setup() {
|
|
setup_asdf_dir
|
|
setup_repo
|
|
install_dummy_plugin
|
|
}
|
|
|
|
teardown() {
|
|
clean_asdf_dir
|
|
}
|
|
|
|
@test "plugin_list_all should exit before syncing the plugin repo if disabled" {
|
|
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
|
|
echo 'disable_plugin_short_name_repository=yes' >"$ASDF_CONFIG_DEFAULT_FILE"
|
|
local expected="Short-name plugin repository is disabled"
|
|
|
|
run asdf plugin list all
|
|
[ "$status" -eq 1 ]
|
|
[ "$output" = "$expected" ]
|
|
}
|
|
|
|
@test "plugin_list_all should sync repo when check_duration set to 0" {
|
|
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
|
|
echo 'plugin_repository_last_check_duration = 0' >"$ASDF_CONFIG_DEFAULT_FILE"
|
|
local expected_plugins_list="\
|
|
bar http://example.com/bar
|
|
dummy http://example.com/dummy
|
|
foo http://example.com/foo"
|
|
|
|
run asdf plugin list all
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"$expected_plugins_list"* ]]
|
|
}
|
|
|
|
@test "plugin_list_all no immediate repo sync expected because check_duration is greater than 0" {
|
|
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
|
|
echo 'plugin_repository_last_check_duration = 10' >"$ASDF_CONFIG_DEFAULT_FILE"
|
|
local expected="\
|
|
bar http://example.com/bar
|
|
dummy http://example.com/dummy
|
|
foo http://example.com/foo"
|
|
|
|
run asdf plugin list all
|
|
[ "$status" -eq 0 ]
|
|
[ "$output" = "$expected" ]
|
|
}
|
|
|
|
@test "plugin_list_all skips repo sync because check_duration is set to never" {
|
|
export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
|
|
echo 'plugin_repository_last_check_duration = never' >"$ASDF_CONFIG_DEFAULT_FILE"
|
|
local expected="\
|
|
bar http://example.com/bar
|
|
dummy http://example.com/dummy
|
|
foo http://example.com/foo"
|
|
|
|
run asdf plugin list all
|
|
[ "$status" -eq 0 ]
|
|
[ "$output" = "$expected" ]
|
|
}
|
|
|
|
@test "plugin_list_all list all plugins in the repository" {
|
|
local expected="\
|
|
bar http://example.com/bar
|
|
dummy http://example.com/dummy
|
|
foo http://example.com/foo"
|
|
|
|
run asdf plugin list all
|
|
[ "$status" -eq 0 ]
|
|
[ "$output" = "$expected" ]
|
|
}
|