acc: add $UNIQUE_NAME env var and replacement (#2474)

Useful for integration tests where project names must be unique. I'm
using it in #2471
This commit is contained in:
Denis Bilenko 2025-03-12 11:14:05 +01:00 committed by GitHub
parent 6a7c7d75d7
commit f8f3d669bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package acceptance_test
import (
"bufio"
"context"
"encoding/base32"
"encoding/json"
"errors"
"flag"
@ -258,6 +259,10 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
}
}
id := uuid.New()
uniqueName := strings.Trim(base32.StdEncoding.EncodeToString(id[:]), "=")
repls.Set(uniqueName, "[UNIQUE_NAME]")
var tmpDir string
var err error
if KeepTmp {
@ -283,6 +288,7 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
args := []string{"bash", "-euo", "pipefail", EntryPointScript}
cmd := exec.Command(args[0], args[1:]...)
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "UNIQUE_NAME="+uniqueName)
var workspaceClient *databricks.WorkspaceClient
var user iam.User