diff --git a/test/latest_command.bats b/test/latest_command.bats index 76fdc1f8b..936ef0489 100644 --- a/test/latest_command.bats +++ b/test/latest_command.bats @@ -22,3 +22,9 @@ teardown() { [ "$(echo "1.1")" == "$output" ] [ "$status" -eq 0 ] } + +@test "latest_command with an invalid version should return an error" { + run asdf latest dummy 3 + [ "$(echo "No compatible versions available (dummy 3)")" == "$output" ] + [ "$status" -eq 1 ] +} diff --git a/test/list_command.bats b/test/list_command.bats index 0a819898d..be9eccedd 100644 --- a/test/list_command.bats +++ b/test/list_command.bats @@ -47,6 +47,14 @@ teardown() { [ "$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 ] +} + @test "list_all_command lists available versions" { run asdf list-all dummy [ "$(echo -e "1.0\n1.1\n2.0")" == "$output" ] @@ -58,3 +66,9 @@ teardown() { [ "$(echo -e "1.0\n1.1")" == "$output" ] [ "$status" -eq 0 ] } + +@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 ] +} diff --git a/test/version_commands.bats b/test/version_commands.bats index 6aad56db4..febe0dc61 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -58,6 +58,12 @@ teardown() { [ "$(cat $PROJECT_DIR/.tool-versions)" = "dummy 1.0.0" ] } +@test "local with latest:version should return an error for invalid versions" { + run asdf local "dummy" "latest:2" + [ "$status" -eq 1 ] + [ "$output" = "$(echo "No compatible versions installed (dummy 2)")" ] +} + @test "local should allow multiple versions" { run asdf local "dummy" "1.1.0" "1.0.0" [ "$status" -eq 0 ] @@ -164,6 +170,12 @@ teardown() { [ "$(cat $HOME/.tool-versions)" = "dummy 1.0.0" ] } +@test "global with latest:version should return an error for invalid versions" { + run asdf global "dummy" "latest:2" + [ "$status" -eq 1 ] + [ "$output" = "$(echo "No compatible versions installed (dummy 2)")" ] +} + @test "global should accept multiple versions" { run asdf global "dummy" "1.1.0" "1.0.0" [ "$status" -eq 0 ]