2016-12-10 12:54:22 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
setup_asdf_dir
|
|
|
|
install_dummy_plugin
|
2021-05-19 02:51:45 -07:00
|
|
|
install_dummy_broken_plugin
|
2022-06-21 05:54:02 -07:00
|
|
|
|
|
|
|
PROJECT_DIR=$HOME/project
|
|
|
|
mkdir $PROJECT_DIR
|
2016-12-10 12:54:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
clean_asdf_dir
|
|
|
|
}
|
|
|
|
|
2018-04-16 15:37:22 -07:00
|
|
|
@test "list_command should list plugins with installed versions" {
|
2020-09-18 22:37:52 -07:00
|
|
|
run asdf install dummy 1.0.0
|
|
|
|
run asdf install dummy 1.1.0
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf list
|
2022-05-12 04:48:54 -07:00
|
|
|
[[ "$output" == *"$(echo -e "dummy\n 1.0.0\n 1.1.0")"* ]]
|
|
|
|
[[ "$output" == *"$(echo -e "dummy-broken\n No versions installed")"* ]]
|
2018-04-16 15:37:22 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
2022-06-21 05:54:02 -07:00
|
|
|
@test "list_command should list plugins with installed versions and any selected versions marked with asterisk" {
|
|
|
|
cd $PROJECT_DIR
|
|
|
|
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
|
|
|
|
run asdf install dummy 1.0.0
|
|
|
|
run asdf install dummy 1.1.0
|
|
|
|
|
|
|
|
run asdf list
|
|
|
|
[[ "$output" == *"$(echo -e "dummy\n 1.0.0\n *1.1.0")"* ]]
|
|
|
|
[[ "$output" == *"$(echo -e "dummy-broken\n No versions installed")"* ]]
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
2018-12-27 18:13:16 -07:00
|
|
|
@test "list_command should continue listing even when no version is installed for any of the plugins" {
|
|
|
|
run install_mock_plugin "dummy"
|
|
|
|
run install_mock_plugin "mummy"
|
|
|
|
run install_mock_plugin "tummy"
|
2020-09-18 22:37:52 -07:00
|
|
|
run asdf install dummy 1.0.0
|
|
|
|
run asdf install tummy 2.0.0
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf list
|
2022-05-12 04:48:54 -07:00
|
|
|
[[ "$output" == *"$(echo -e "dummy\n 1.0.0")"* ]]
|
2021-05-19 02:51:45 -07:00
|
|
|
[[ "$output" == *"$(echo -e "dummy-broken\n No versions installed")"* ]]
|
|
|
|
[[ "$output" == *"$(echo -e "mummy\n No versions installed")"* ]]
|
2022-05-12 04:48:54 -07:00
|
|
|
[[ "$output" == *"$(echo -e "tummy\n 2.0.0")"* ]]
|
2018-12-27 18:13:16 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2016-12-10 12:54:22 -07:00
|
|
|
}
|
|
|
|
|
2018-04-16 15:37:22 -07:00
|
|
|
@test "list_command with plugin should list installed versions" {
|
2020-09-18 22:37:52 -07:00
|
|
|
run asdf install dummy 1.0.0
|
|
|
|
run asdf install dummy 1.1.0
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf list dummy
|
2020-09-18 22:37:52 -07:00
|
|
|
[ "$(echo -e " 1.0.0\n 1.1.0")" == "$output" ]
|
2016-12-10 12:54:22 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
2019-11-22 11:37:53 -07:00
|
|
|
|
2021-07-06 04:17:00 -07:00
|
|
|
@test "list_command with version filters installed versions" {
|
|
|
|
run asdf install dummy 1.0
|
|
|
|
run asdf install dummy 1.1
|
|
|
|
run asdf install dummy 2.0
|
|
|
|
run asdf list dummy 1
|
|
|
|
[ "$(echo -e " 1.0\n 1.1")" == "$output" ]
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "list_command with an invalid version should return an error" {
|
|
|
|
run asdf install dummy 1.0
|
|
|
|
run asdf install dummy 1.1
|
|
|
|
run asdf list dummy 2
|
|
|
|
[ "$(echo "No compatible versions installed (dummy 2)")" == "$output" ]
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
|
|
|
|
2019-11-22 11:37:53 -07:00
|
|
|
@test "list_all_command lists available versions" {
|
|
|
|
run asdf list-all dummy
|
2020-09-18 22:37:52 -07:00
|
|
|
[ "$(echo -e "1.0.0\n1.1.0\n2.0.0")" == "$output" ]
|
2019-11-22 11:37:53 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "list_all_command with version filters available versions" {
|
|
|
|
run asdf list-all dummy 1
|
2020-09-18 22:37:52 -07:00
|
|
|
[ "$(echo -e "1.0.0\n1.1.0")" == "$output" ]
|
2019-11-22 11:37:53 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
2021-05-19 02:51:45 -07:00
|
|
|
|
2021-07-06 04:17:00 -07:00
|
|
|
@test "list_all_command with an invalid version should return an error" {
|
|
|
|
run asdf list-all dummy 3
|
|
|
|
[ "$(echo "No compatible versions available (dummy 3)")" == "$output" ]
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
|
|
|
|
2021-05-19 02:51:45 -07:00
|
|
|
@test "list_all_command fails when list-all script exits with non-zero code" {
|
|
|
|
run asdf list-all dummy-broken
|
|
|
|
echo $output
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
[[ "$output" == "Plugin dummy-broken's list-all callback script failed with output:"* ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "list_all_command displays stderr then stdout when failing" {
|
|
|
|
run asdf list-all dummy-broken
|
|
|
|
echo $output
|
|
|
|
[[ "$output" == *"List-all failed!"* ]]
|
|
|
|
[[ "$output" == *"Attempting to list versions" ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "list_all_command ignores stderr when completing successfully" {
|
|
|
|
run asdf list-all dummy
|
|
|
|
[[ "$output" != *"ignore this error"* ]]
|
|
|
|
}
|