Add test for invalid asdf install arguments

This commit is contained in:
Dan Fuchs 2020-07-09 21:18:16 -05:00
parent 5578b7849c
commit d7e1e66c03
2 changed files with 19 additions and 1 deletions

View File

@ -1,5 +1,15 @@
#!/usr/bin/env bash
# We want certain versions to fail installation for various reasons in the tests
check_dummy_versions() {
local bad_versions=" other-dummy "
if [[ "$bad_versions" == *" $ASDF_INSTALL_VERSION "* ]]; then
echo "Dummy couldn't install version: $ASDF_INSTALL_VERSION (on purpose)"
exit 1
fi
}
check_dummy_versions
mkdir -p "$ASDF_INSTALL_PATH"
env >"$ASDF_INSTALL_PATH/env"
echo "$ASDF_INSTALL_VERSION" >"$ASDF_INSTALL_PATH/version"

View File

@ -133,7 +133,6 @@ teardown() {
}
@test "install_command fails when tool is specified but no version of the tool is configured in config file" {
echo 'dummy 1.0' > $PROJECT_DIR/.tool-versions
run asdf install other-dummy
[ "$status" -eq 1 ]
@ -141,6 +140,15 @@ teardown() {
[ ! -f $ASDF_DIR/installs/dummy/1.0/version ]
}
@test "install_command fails when two tools are specified with no versions" {
printf 'dummy 1.0\nother-dummy 2.0' > $PROJECT_DIR/.tool-versions
run asdf install dummy other-dummy
[ "$status" -eq 1 ]
[ "$output" = "Dummy couldn't install version: other-dummy (on purpose)" ]
[ ! -f $ASDF_DIR/installs/dummy/1.0/version ]
[ ! -f $ASDF_DIR/installs/other-dummy/2.0/version ]
}
@test "install_command without arguments uses a parent directory .tool-versions file if present" {
# asdf lib needed to run generated shims
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/