Skip to content

Commit

Permalink
Add tests for version filtering error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
klane committed Jan 7, 2020
1 parent 7484fcb commit 4254190
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/latest_command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
}
14 changes: 14 additions & 0 deletions test/list_command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand All @@ -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 ]
}
12 changes: 12 additions & 0 deletions test/version_commands.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down Expand Up @@ -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 ]
Expand Down

0 comments on commit 4254190

Please sign in to comment.