Skip to content

Commit

Permalink
chore: update tests to new output
Browse files Browse the repository at this point in the history
  • Loading branch information
jthegedus committed Nov 14, 2021
1 parent 78651a2 commit 5494ad9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 76 deletions.
27 changes: 13 additions & 14 deletions test/current_command.bats
Expand Up @@ -19,7 +19,7 @@ teardown() {

@test "current should derive from the current .tool-versions" {
cd $PROJECT_DIR
echo 'dummy 1.1.0' >> $PROJECT_DIR/.tool-versions
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
expected="dummy 1.1.0 $PROJECT_DIR/.tool-versions"

run asdf current "dummy"
Expand All @@ -29,7 +29,7 @@ teardown() {

@test "current should handle long version name" {
cd $PROJECT_DIR
echo "dummy nightly-2000-01-01" >> $PROJECT_DIR/.tool-versions
echo "dummy nightly-2000-01-01" >>$PROJECT_DIR/.tool-versions
expected="dummy nightly-2000-01-01 $PROJECT_DIR/.tool-versions"

run asdf current "dummy"
Expand All @@ -39,19 +39,18 @@ teardown() {

@test "current should handle multiple versions" {
cd $PROJECT_DIR
echo "dummy 1.2.0 1.1.0" >> $PROJECT_DIR/.tool-versions
echo "dummy 1.2.0 1.1.0" >>$PROJECT_DIR/.tool-versions
expected="dummy 1.2.0 1.1.0 $PROJECT_DIR/.tool-versions"

run asdf current "dummy"
[ "$status" -eq 0 ]
[ "$output" = "$expected" ]
}


@test "current should derive from the legacy file if enabled" {
cd $PROJECT_DIR
echo 'legacy_version_file = yes' > $HOME/.asdfrc
echo '1.2.0' >> $PROJECT_DIR/.dummy-version
echo 'legacy_version_file = yes' >$HOME/.asdfrc
echo '1.2.0' >>$PROJECT_DIR/.dummy-version
expected="dummy 1.2.0 $PROJECT_DIR/.dummy-version"

run asdf current "dummy"
Expand All @@ -70,7 +69,7 @@ teardown() {

@test "current should error when no version is set" {
cd $PROJECT_DIR
expected="dummy ______ No version set. Run \"asdf <global|shell|local> dummy <version>\""
expected="dummy ______ no version is set. Run \"asdf <global|shell|local> dummy <version>\""

run asdf current "dummy"
[ "$status" -eq 126 ]
Expand All @@ -79,7 +78,7 @@ teardown() {

@test "current should error when a version is set that isn't installed" {
cd $PROJECT_DIR
echo 'dummy 9.9.9' >> $PROJECT_DIR/.tool-versions
echo 'dummy 9.9.9' >>$PROJECT_DIR/.tool-versions
expected="dummy 9.9.9 Not installed. Run \"asdf install dummy 9.9.9\""

run asdf current "dummy"
Expand All @@ -98,11 +97,11 @@ teardown() {
install_mock_plugin "baz"

cd $PROJECT_DIR
echo 'dummy 1.1.0' >> $PROJECT_DIR/.tool-versions
echo 'foobar 1.0.0' >> $PROJECT_DIR/.tool-versions
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
echo 'foobar 1.0.0' >>$PROJECT_DIR/.tool-versions

run asdf current
expected="baz ______ No version set. Run \"asdf <global|shell|local> baz <version>\"
expected="baz ______ no version is set. Run \"asdf <global|shell|local> baz <version>\"
dummy 1.1.0 $PROJECT_DIR/.tool-versions
foobar 1.0.0 $PROJECT_DIR/.tool-versions"

Expand All @@ -117,8 +116,8 @@ foobar 1.0.0 $PROJECT_DIR/.tool-versions"
install_mock_plugin_version "y" "2.1.0"

cd $PROJECT_DIR
echo 'dummy 1.1.0' >> $PROJECT_DIR/.tool-versions
echo 'y 2.1.0' >> $PROJECT_DIR/.tool-versions
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
echo 'y 2.1.0' >>$PROJECT_DIR/.tool-versions

run asdf current "y"
[ "$status" -eq 0 ]
Expand All @@ -136,7 +135,7 @@ foobar 1.0.0 $PROJECT_DIR/.tool-versions"

@test "current should handle comments" {
cd $PROJECT_DIR
echo "dummy 1.2.0 # this is a comment" >> $PROJECT_DIR/.tool-versions
echo "dummy 1.2.0 # this is a comment" >>$PROJECT_DIR/.tool-versions
expected="dummy 1.2.0 $PROJECT_DIR/.tool-versions"

run asdf current "dummy"
Expand Down

0 comments on commit 5494ad9

Please sign in to comment.