mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
66 lines
1.7 KiB
Bash
66 lines
1.7 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helpers
|
|
|
|
setup() {
|
|
BASE_DIR=$(mktemp -dt asdf.XXXX)
|
|
HOME=$BASE_DIR/home
|
|
ASDF_DIR=$HOME/.asdf
|
|
git clone -o local "$(dirname "$BATS_TEST_DIRNAME")" "$ASDF_DIR"
|
|
git --git-dir "$ASDF_DIR/.git" remote add origin https://github.com/asdf-vm/asdf.git
|
|
mkdir -p "$ASDF_DIR/plugins"
|
|
ASDF_BIN="$ASDF_DIR/bin"
|
|
|
|
# shellcheck disable=SC2031
|
|
PATH=$ASDF_BIN:$ASDF_DIR/shims:$PATH
|
|
install_dummy_plugin
|
|
|
|
PROJECT_DIR=$HOME/project
|
|
mkdir $PROJECT_DIR
|
|
}
|
|
|
|
teardown() {
|
|
clean_asdf_dir
|
|
}
|
|
|
|
@test "asdf plugin-update should pull latest master branch for plugin" {
|
|
run asdf plugin-update dummy
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" =~ "Updating dummy..."* ]]
|
|
cd $ASDF_DIR/plugins/dummy
|
|
[ $(git rev-parse --abbrev-ref HEAD) = "master" ]
|
|
}
|
|
|
|
@test "asdf plugin-update should not remove plugin versions" {
|
|
run asdf install dummy 1.1
|
|
[ "$status" -eq 0 ]
|
|
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
|
run asdf plugin-update dummy
|
|
[ "$status" -eq 0 ]
|
|
[ -f $ASDF_DIR/installs/dummy/1.1/version ]
|
|
run asdf plugin-update --all
|
|
[ "$status" -eq 0 ]
|
|
[ -f $ASDF_DIR/installs/dummy/1.1/version ]
|
|
}
|
|
|
|
@test "asdf plugin-update should not remove plugins" {
|
|
# dummy plugin is already installed
|
|
run asdf plugin-update dummy
|
|
[ "$status" -eq 0 ]
|
|
[ -d $ASDF_DIR/plugins/dummy ]
|
|
run asdf plugin-update --all
|
|
[ "$status" -eq 0 ]
|
|
[ -d $ASDF_DIR/plugins/dummy ]
|
|
}
|
|
|
|
@test "asdf plugin-update should not remove shims" {
|
|
run asdf install dummy 1.1
|
|
[ -f $ASDF_DIR/shims/dummy ]
|
|
run asdf plugin-update dummy
|
|
[ "$status" -eq 0 ]
|
|
[ -f $ASDF_DIR/shims/dummy ]
|
|
run asdf plugin-update --all
|
|
[ "$status" -eq 0 ]
|
|
[ -f $ASDF_DIR/shims/dummy ]
|
|
}
|