2017-07-26 13:00:55 -07:00
|
|
|
#!/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 "reshim command should remove shims of removed binaries" {
|
|
|
|
run install_command dummy 1.0
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
|
|
|
|
run reshim_command dummy
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
|
|
|
|
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
|
|
|
|
run reshim_command dummy
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ ! -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "reshim should remove metadata of removed binaries" {
|
|
|
|
run install_command dummy 1.0
|
|
|
|
run install_command dummy 1.1
|
|
|
|
|
|
|
|
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
|
|
|
|
run reshim_command dummy
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
run grep "asdf-plugin-version: 1.0" "$ASDF_DIR/shims/dummy"
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
run grep "asdf-plugin-version: 1.1" "$ASDF_DIR/shims/dummy"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
2017-10-25 12:05:59 -07:00
|
|
|
|
|
|
|
@test "reshim should not duplicate shims" {
|
2017-10-25 12:19:03 -07:00
|
|
|
cd $PROJECT_DIR
|
|
|
|
|
2017-10-26 12:58:45 -07:00
|
|
|
run install_command dummy 1.0
|
|
|
|
run install_command dummy 1.1
|
2017-10-25 12:05:59 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
|
|
|
|
run rm $ASDF_DIR/shims/*
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "0" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
|
|
|
|
|
|
run reshim_command dummy
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
2017-10-25 12:14:19 -07:00
|
|
|
|
|
|
|
run reshim_command dummy
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
2017-10-26 12:58:45 -07:00
|
|
|
}
|
2018-09-19 05:00:11 -07:00
|
|
|
|
|
|
|
@test "reshim should create shims only for files and not folders" {
|
|
|
|
cd $PROJECT_DIR
|
|
|
|
|
|
|
|
run install_command dummy 1.0
|
|
|
|
run install_command dummy 1.1
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
[ ! -f "$ASDF_DIR/shims/subdir" ]
|
|
|
|
|
|
|
|
run rm $ASDF_DIR/shims/*
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "0" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
|
|
[ "0" -eq "$(ls $ASDF_DIR/shims/subdir* | wc -l)" ]
|
|
|
|
|
|
|
|
run reshim_command dummy
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
|
|
[ "0" -eq "$(ls $ASDF_DIR/shims/subdir* | wc -l)" ]
|
|
|
|
|
|
|
|
}
|