2019-11-22 11:37:53 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
setup_asdf_dir
|
|
|
|
install_dummy_plugin
|
2021-07-06 19:51:19 -07:00
|
|
|
install_dummy_legacy_plugin
|
2019-11-22 11:37:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
clean_asdf_dir
|
|
|
|
}
|
|
|
|
|
2021-07-06 19:51:19 -07:00
|
|
|
####################################################
|
|
|
|
#### plugin with bin/latest-stable ####
|
|
|
|
####################################################
|
|
|
|
@test "[latest_command - dummy_plugin] shows latest stable version" {
|
2019-11-22 11:37:53 -07:00
|
|
|
run asdf latest dummy
|
2023-01-27 05:17:41 -07:00
|
|
|
[ "2.0.0" = "$output" ]
|
2019-11-22 11:37:53 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
2021-07-06 19:51:19 -07:00
|
|
|
@test "[latest_command - dummy_plugin] shows latest stable version that matches the given string" {
|
2019-11-22 11:37:53 -07:00
|
|
|
run asdf latest dummy 1
|
2023-01-27 05:17:41 -07:00
|
|
|
[ "1.1.0" = "$output" ]
|
2019-11-22 11:37:53 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
2021-07-06 04:17:00 -07:00
|
|
|
|
2021-07-06 19:51:19 -07:00
|
|
|
@test "[latest_command - dummy_plugin] an invalid version should return an error" {
|
2021-07-06 04:17:00 -07:00
|
|
|
run asdf latest dummy 3
|
2023-01-27 05:17:41 -07:00
|
|
|
[ "No compatible versions available (dummy 3)" = "$output" ]
|
2021-07-06 04:17:00 -07:00
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
2021-07-06 19:51:19 -07:00
|
|
|
|
|
|
|
####################################################
|
|
|
|
#### plugin without bin/latest-stable ####
|
|
|
|
####################################################
|
|
|
|
@test "[latest_command - dummy_legacy_plugin] shows latest stable version" {
|
|
|
|
run asdf latest legacy-dummy
|
2023-01-27 05:17:41 -07:00
|
|
|
[ "5.1.0" = "$output" ]
|
2021-07-06 19:51:19 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "[latest_command - dummy_legacy_plugin] shows latest stable version that matches the given string" {
|
|
|
|
run asdf latest legacy-dummy 1
|
2023-01-27 05:17:41 -07:00
|
|
|
[ "1.1.0" = "$output" ]
|
2021-07-06 19:51:19 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
2021-12-29 06:50:06 -07:00
|
|
|
@test "[latest_command - dummy_legacy_plugin] No stable version should return an error" {
|
2021-07-06 19:51:19 -07:00
|
|
|
run asdf latest legacy-dummy 3
|
2021-12-29 06:50:06 -07:00
|
|
|
[ -z "$output" ]
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "[latest_command - dummy_legacy_plugin] do not show latest unstable version that matches the given string" {
|
|
|
|
run asdf latest legacy-dummy 4
|
2023-01-27 05:17:41 -07:00
|
|
|
[ "4.0.0" = "$output" ]
|
2021-12-29 06:50:06 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "[latest_command - dummy_legacy_plugin] do not show latest unstable version with capital characters that matches the given string" {
|
|
|
|
run asdf latest legacy-dummy 5
|
2023-01-27 05:17:41 -07:00
|
|
|
[ "5.1.0" = "$output" ]
|
2021-12-29 06:50:06 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "[latest_command - dummy_legacy_plugin] an invalid version should return an error" {
|
|
|
|
run asdf latest legacy-dummy 6
|
2023-01-27 05:17:41 -07:00
|
|
|
[ "No compatible versions available (legacy-dummy 6)" = "$output" ]
|
2021-07-06 19:51:19 -07:00
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
2021-12-05 05:41:27 -07:00
|
|
|
|
|
|
|
################################
|
|
|
|
#### latest --all ####
|
|
|
|
################################
|
|
|
|
@test "[latest_command - all plugins] shows the latest stable version of all plugins" {
|
2021-12-08 22:49:24 -07:00
|
|
|
run asdf install dummy 2.0.0
|
2021-12-29 06:50:06 -07:00
|
|
|
run asdf install legacy-dummy 4.0.0
|
2021-12-05 05:41:27 -07:00
|
|
|
run asdf latest --all
|
2023-04-10 20:58:58 -07:00
|
|
|
[ $'dummy\t2.0.0\tinstalled\nlegacy-dummy\t5.1.0\tmissing' = "$output" ]
|
2021-12-08 22:49:24 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "[latest_command - all plugins] not installed plugin should return missing" {
|
|
|
|
run asdf latest --all
|
2023-04-10 20:58:58 -07:00
|
|
|
[ $'dummy\t2.0.0\tmissing\nlegacy-dummy\t5.1.0\tmissing' = "$output" ]
|
2021-12-05 05:41:27 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|