2017-08-31 20:21:09 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# shellcheck source=lib/utils.sh
|
2016-06-28 20:56:33 -07:00
|
|
|
. $(dirname $BATS_TEST_DIRNAME)/lib/utils.sh
|
|
|
|
|
|
|
|
setup_asdf_dir() {
|
|
|
|
BASE_DIR=$(mktemp -dt asdf.XXXX)
|
|
|
|
HOME=$BASE_DIR/home
|
|
|
|
ASDF_DIR=$HOME/.asdf
|
2017-08-31 20:21:09 -07:00
|
|
|
mkdir -p "$ASDF_DIR/plugins"
|
|
|
|
mkdir -p "$ASDF_DIR/installs"
|
|
|
|
mkdir -p "$ASDF_DIR/shims"
|
|
|
|
mkdir -p "$ASDF_DIR/tmp"
|
2016-07-05 23:32:57 -07:00
|
|
|
PATH=$ASDF_DIR/shims:$PATH
|
2016-06-28 20:56:33 -07:00
|
|
|
}
|
|
|
|
|
2017-08-18 21:56:28 -07:00
|
|
|
install_mock_plugin() {
|
|
|
|
local plugin_name=$1
|
|
|
|
cp -r "$BATS_TEST_DIRNAME/fixtures/dummy_plugin" "$ASDF_DIR/plugins/$plugin_name"
|
|
|
|
}
|
|
|
|
|
|
|
|
install_mock_plugin_version() {
|
|
|
|
local plugin_name=$1
|
|
|
|
local plugin_version=$2
|
|
|
|
mkdir -p "$ASDF_DIR/installs/$plugin_name/$plugin_version"
|
|
|
|
}
|
|
|
|
|
2016-06-28 20:56:33 -07:00
|
|
|
install_dummy_plugin() {
|
2017-08-18 21:56:28 -07:00
|
|
|
install_mock_plugin "dummy"
|
2016-06-28 20:56:33 -07:00
|
|
|
}
|
|
|
|
|
2016-07-23 00:15:05 -07:00
|
|
|
install_dummy_version() {
|
2017-08-18 21:56:28 -07:00
|
|
|
install_mock_plugin_version "dummy" "$1"
|
2016-07-23 00:15:05 -07:00
|
|
|
}
|
|
|
|
|
2016-06-28 20:56:33 -07:00
|
|
|
clean_asdf_dir() {
|
2017-08-31 20:21:09 -07:00
|
|
|
rm -rf "$BASE_DIR"
|
2016-06-28 20:56:33 -07:00
|
|
|
unset ASDF_DIR
|
|
|
|
}
|
2017-08-24 19:29:23 -07:00
|
|
|
|
|
|
|
setup_repo() {
|
2017-10-02 06:51:07 -07:00
|
|
|
cp -r "$BATS_TEST_DIRNAME/fixtures/dummy_plugins_repo" "$ASDF_DIR/repository"
|
2017-08-24 19:29:23 -07:00
|
|
|
touch "$(asdf_dir)/tmp/repo-updated"
|
|
|
|
}
|