2016-07-24 08:47:17 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
|
|
|
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/current.sh
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
setup_asdf_dir
|
|
|
|
install_dummy_plugin
|
2016-07-30 16:48:57 -07:00
|
|
|
install_dummy_version "1.1.0"
|
|
|
|
install_dummy_version "1.2.0"
|
2016-07-24 08:47:17 -07:00
|
|
|
|
|
|
|
PROJECT_DIR=$HOME/project
|
2016-07-30 16:48:57 -07:00
|
|
|
mkdir $PROJECT_DIR
|
2016-07-24 08:47:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
clean_asdf_dir
|
|
|
|
}
|
|
|
|
|
2016-07-30 16:48:57 -07:00
|
|
|
@test "current should derive from the current .tool-versions" {
|
2016-07-24 08:47:17 -07:00
|
|
|
cd $PROJECT_DIR
|
2016-07-30 16:48:57 -07:00
|
|
|
echo 'dummy 1.1.0' >> $PROJECT_DIR/.tool-versions
|
2016-07-24 08:47:17 -07:00
|
|
|
|
|
|
|
run current_command "dummy"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "1.1.0 (set by $PROJECT_DIR/.tool-versions)" ]
|
|
|
|
}
|
|
|
|
|
2016-07-30 16:48:57 -07:00
|
|
|
@test "current should derive from the legacy file if enabled" {
|
|
|
|
cd $PROJECT_DIR
|
2016-07-24 08:47:17 -07:00
|
|
|
echo 'legacy_version_file = yes' > $HOME/.asdfrc
|
2016-07-30 16:48:57 -07:00
|
|
|
echo '1.2.0' >> $PROJECT_DIR/.dummy-version
|
2016-07-24 08:47:17 -07:00
|
|
|
|
|
|
|
run current_command "dummy"
|
|
|
|
[ "$status" -eq 0 ]
|
2016-07-30 16:48:57 -07:00
|
|
|
[ "$output" = "1.2.0 (set by $PROJECT_DIR/.dummy-version)" ]
|
2016-07-24 08:47:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "current should error when the plugin doesn't exist" {
|
|
|
|
run current_command "foobar"
|
|
|
|
[ "$status" -eq 1 ]
|
2016-07-30 16:48:57 -07:00
|
|
|
[ "$output" = "No such plugin" ]
|
2016-07-24 08:47:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "current should error when no version is set" {
|
2016-07-30 16:48:57 -07:00
|
|
|
cd $PROJECT_DIR
|
|
|
|
|
|
|
|
run current_command "dummy"
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
2016-07-24 08:47:17 -07:00
|
|
|
|
|
|
|
run current_command "dummy"
|
|
|
|
[ "$status" -eq 1 ]
|
2016-07-30 16:48:57 -07:00
|
|
|
[ "$output" = "version 9.9.9 is not installed for dummy" ]
|
2016-07-24 08:47:17 -07:00
|
|
|
}
|