asdf/test/install_command.bats
Victor Borja 7512d9abf4 Add metadata to shims
When a shim is created, add plugin metadata so we can later know which shims belong to which plugins, this will help aid with removing unused shims on uninstall. See #67

```
# asdf-plugin: ${plugin_name}”
```

Thanks to @duijf for the metadata proposal.
2016-12-10 12:17:50 -06:00

53 lines
1.2 KiB
Bash

#!/usr/bin/env bats
load test_helpers
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/reshim.sh
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/install.sh
setup() {
setup_asdf_dir
install_dummy_plugin
PROJECT_DIR=$HOME/project
mkdir $PROJECT_DIR
}
teardown() {
clean_asdf_dir
}
@test "install_command installs the correct version" {
run install_command dummy 1.1
[ "$status" -eq 0 ]
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
}
@test "install_command set ASDF_CONCURRENCY" {
run install_command dummy 1.0
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/dummy/1.0/env ]
run grep ASDF_CONCURRENCY $ASDF_DIR/installs/dummy/1.0/env
[ "$status" -eq 0 ]
}
@test "install_command should work in directory containing whitespace" {
WHITESPACE_DIR="$PROJECT_DIR/whitespace\ dir"
mkdir -p "$WHITESPACE_DIR"
cd "$WHITESPACE_DIR"
echo 'dummy 1.2' >> "$WHITESPACE_DIR/.tool-versions"
run install_command
[ "$status" -eq 0 ]
[ $(cat $ASDF_DIR/installs/dummy/1.2/version) = "1.2" ]
}
@test "install_command should create a shim with metadada" {
run install_command dummy 1.0
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/dummy/1.0/env ]
run grep "# asdf-plugin: dummy" $ASDF_DIR/shims/dummy
[ "$status" -eq 0 ]
}