feat(golang-rewrite): set variables for bats integration tests

This commit is contained in:
Trevor Brown 2024-02-10 19:25:42 -05:00
parent 477e9d5729
commit 2951011090
2 changed files with 8 additions and 5 deletions

View File

@ -131,9 +131,10 @@ func run_bats_file(t *testing.T, dir, filename string) {
cmd.Stdout = &stdout
cmd.Stderr = &stderr
// Add dir to front of path
path := os.Getenv("PATH")
cmd.Env = append(cmd.Environ(), fmt.Sprintf("PATH=%s:%s", dir, path))
// Add dir to asdf test variables
asdf_test_home := fmt.Sprintf("HOME=%s/.asdf/", dir)
asdf_bin_path := fmt.Sprintf("ASDF_BIN=%s", dir)
cmd.Env = append(cmd.Environ(), asdf_bin_path, asdf_test_home)
err := cmd.Run()
if err != nil {

View File

@ -12,13 +12,15 @@ setup_asdf_dir() {
BASE_DIR="$(mktemp -dt "asdf with spaces.XXXX")"
fi
HOME="$BASE_DIR/home"
# HOME is now defined by the Golang test code in main_test.go
#HOME="$BASE_DIR/home"
ASDF_DIR="$HOME/.asdf"
mkdir -p "$ASDF_DIR/plugins"
mkdir -p "$ASDF_DIR/installs"
mkdir -p "$ASDF_DIR/shims"
mkdir -p "$ASDF_DIR/tmp"
ASDF_BIN="$(dirname "$BATS_TEST_DIRNAME")/bin"
# ASDF_BIN is now defined by the Golang test code in main_test.go
#ASDF_BIN="$(dirname "$BATS_TEST_DIRNAME")/bin"
# shellcheck disable=SC2031
PATH="$ASDF_BIN:$ASDF_DIR/shims:$PATH"