2018-10-28 10:47:21 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
2023-01-28 20:52:22 -07:00
|
|
|
setup() {
|
2018-10-28 10:47:21 -07:00
|
|
|
setup_asdf_dir
|
|
|
|
install_dummy_plugin
|
|
|
|
install_dummy_version 1.0
|
|
|
|
install_dummy_version 2.1
|
|
|
|
install_dummy_version ref-master
|
|
|
|
}
|
|
|
|
|
2023-01-28 20:52:22 -07:00
|
|
|
teardown() {
|
2018-10-28 10:47:21 -07:00
|
|
|
clean_asdf_dir
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "where shows install location of selected version" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf where 'dummy' '1.0'
|
2018-10-28 10:47:21 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$ASDF_DIR/installs/dummy/1.0" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "where understands versions installed by ref" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf where 'dummy' 'ref:master'
|
2018-10-28 10:47:21 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$ASDF_DIR/installs/dummy/ref-master" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "where shows install location of current version if no version specified" {
|
2023-01-22 21:29:18 -07:00
|
|
|
echo 'dummy 2.1' >>"$HOME/.tool-versions"
|
2018-10-28 10:47:21 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf where 'dummy'
|
2018-10-28 10:47:21 -07:00
|
|
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$ASDF_DIR/installs/dummy/2.1" ]
|
|
|
|
}
|
|
|
|
|
2020-08-28 02:24:59 -07:00
|
|
|
@test "where shows install location of first current version if not version specified and multiple current versions" {
|
2023-01-22 21:29:18 -07:00
|
|
|
echo 'dummy 2.1 1.0' >>"$HOME/.tool-versions"
|
2020-08-28 02:24:59 -07:00
|
|
|
run asdf where 'dummy'
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$ASDF_DIR/installs/dummy/2.1" ]
|
|
|
|
}
|
|
|
|
|
2018-10-28 10:47:21 -07:00
|
|
|
@test "where should error when the plugin doesn't exist" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf where "foobar"
|
2018-10-28 10:47:21 -07:00
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
[ "$output" = "No such plugin: foobar" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "where should error when version is not installed" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf where 'dummy' '1.6'
|
2018-10-28 10:47:21 -07:00
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
[ "$output" = "Version not installed" ]
|
|
|
|
}
|
|
|
|
|
2019-03-23 07:45:50 -07:00
|
|
|
@test "where should error when system version is set" {
|
|
|
|
run asdf where 'dummy' 'system'
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
[ "$output" = "System version is selected" ]
|
|
|
|
}
|
|
|
|
|
2018-10-28 10:47:21 -07:00
|
|
|
@test "where should error when no current version selected and version not specified" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf where 'dummy'
|
2018-10-28 10:47:21 -07:00
|
|
|
|
|
|
|
local expected
|
2021-11-13 20:35:42 -07:00
|
|
|
expected="No version is set for dummy; please run \`asdf <global | shell | local> dummy <version>\`"
|
2018-10-28 10:47:21 -07:00
|
|
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
[ "$output" = "$expected" ]
|
|
|
|
}
|