Skip to content

Commit 24f3445

Browse files
committed
consolidating prefix
1 parent 3399d09 commit 24f3445

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

internal/acctest/acctest.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ import (
1818
"github.com/ory/terraform-provider-orynetwork/internal/provider"
1919
)
2020

21-
// Projects with names starting with this prefix are automatically purged by the e2e cleanup job.
22-
// DO NOT CHANGE THIS PREFIX - it must match the pattern in cloud/backoffice/backoffice/x/patterns.go
23-
const TestProjectNamePrefix = "ory-cy-e2e-da2f162d-af61-42dd-90dc-e3fcfa7c84a0"
24-
2521
// TestProject holds information about a test project created for acceptance tests.
2622
type TestProject struct {
2723
ID string
@@ -156,7 +152,14 @@ func createSharedProject(t *testing.T) {
156152
return
157153
}
158154

159-
projectName := fmt.Sprintf("%s-tf-%d", TestProjectNamePrefix, time.Now().UnixNano())
155+
// Use prefix from env var (set by scripts/run-acceptance-tests.sh) for auto-cleanup support
156+
prefix := os.Getenv("ORY_TEST_PROJECT_PREFIX")
157+
var projectName string
158+
if prefix != "" {
159+
projectName = fmt.Sprintf("%s-tf-%d", prefix, time.Now().UnixNano())
160+
} else {
161+
projectName = fmt.Sprintf("tf-acc-test-%d", time.Now().UnixNano())
162+
}
160163
t.Logf("Creating test project: %s (environment: prod)", projectName)
161164

162165
// Create as "prod" environment to support all features including organizations

internal/resources/project/resource_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,13 @@ func TestAccProjectResource_prodEnvironment(t *testing.T) {
7373
}
7474

7575
// testProjectName generates a project name with the e2e prefix for hard deletion support.
76+
// The prefix is read from ORY_TEST_PROJECT_PREFIX env var (set by scripts/run-acceptance-tests.sh).
7677
func testProjectName(suffix string) string {
77-
return fmt.Sprintf("%s-tf-%s-%d", acctest.TestProjectNamePrefix, suffix, time.Now().UnixNano())
78+
prefix := os.Getenv("ORY_TEST_PROJECT_PREFIX")
79+
if prefix != "" {
80+
return fmt.Sprintf("%s-tf-%s-%d", prefix, suffix, time.Now().UnixNano())
81+
}
82+
return fmt.Sprintf("tf-acc-test-%s-%d", suffix, time.Now().UnixNano())
7883
}
7984

8085
func testAccProjectResourceConfig(name, environment string) string {

scripts/run-acceptance-tests.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ parse_curl_response() {
5555
CONSOLE_API_URL="${ORY_CONSOLE_API_URL:-https://api.console.ory.sh}"
5656
PROJECT_API_URL="${ORY_PROJECT_API_URL:-https://%s.projects.oryapis.com}"
5757

58-
# Magic prefix that triggers hard deletion in the Ory Cloud backend.
5958
# Projects with names starting with this prefix are automatically purged by the e2e cleanup job.
6059
# DO NOT CHANGE THIS PREFIX - it must match the pattern in cloud/backoffice/backoffice/x/patterns.go
61-
PROJECT_NAME_PREFIX="ory-cy-e2e-da2f162d-af61-42dd-90dc-e3fcfa7c84a0"
62-
PROJECT_NAME="${PROJECT_NAME_PREFIX}-tf-$(date +%s)"
60+
export ORY_TEST_PROJECT_PREFIX="ory-cy-e2e-da2f162d-af61-42dd-90dc-e3fcfa7c84a0"
61+
PROJECT_NAME="${ORY_TEST_PROJECT_PREFIX}-tf-$(date +%s)"
6362

6463
# Validate required environment variables
6564
if [[ -z "${ORY_WORKSPACE_API_KEY:-}" ]]; then

0 commit comments

Comments
 (0)