66 "fmt"
77 "os"
88 "testing"
9+ "time"
910
1011 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
1112
@@ -27,16 +28,17 @@ func testAccPreCheck(t *testing.T) {
2728// WARNING: This test creates and deletes a real Ory project.
2829// Only run this test if you have quota available and understand the implications.
2930func TestAccProjectResource_basic (t * testing.T ) {
31+ projectName := testProjectName ("basic" )
3032 acctest .RunTest (t , resource.TestCase {
3133 PreCheck : func () { testAccPreCheck (t ) },
3234 ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories (),
3335 Steps : []resource.TestStep {
3436 // Create and Read
3537 {
36- Config : testAccProjectResourceConfig ("tf-test-project" , "dev" ),
38+ Config : testAccProjectResourceConfig (projectName , "dev" ),
3739 Check : resource .ComposeAggregateTestCheckFunc (
3840 resource .TestCheckResourceAttrSet ("ory_project.test" , "id" ),
39- resource .TestCheckResourceAttr ("ory_project.test" , "name" , "tf-test-project" ),
41+ resource .TestCheckResourceAttr ("ory_project.test" , "name" , projectName ),
4042 resource .TestCheckResourceAttr ("ory_project.test" , "environment" , "dev" ),
4143 resource .TestCheckResourceAttrSet ("ory_project.test" , "slug" ),
4244 resource .TestCheckResourceAttr ("ory_project.test" , "state" , "running" ),
@@ -54,12 +56,13 @@ func TestAccProjectResource_basic(t *testing.T) {
5456
5557// TestAccProjectResource_prodEnvironment tests creating a production project.
5658func TestAccProjectResource_prodEnvironment (t * testing.T ) {
59+ projectName := testProjectName ("prod" )
5760 acctest .RunTest (t , resource.TestCase {
5861 PreCheck : func () { testAccPreCheck (t ) },
5962 ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories (),
6063 Steps : []resource.TestStep {
6164 {
62- Config : testAccProjectResourceConfig ("tf-test-prod-project" , "prod" ),
65+ Config : testAccProjectResourceConfig (projectName , "prod" ),
6366 Check : resource .ComposeAggregateTestCheckFunc (
6467 resource .TestCheckResourceAttrSet ("ory_project.test" , "id" ),
6568 resource .TestCheckResourceAttr ("ory_project.test" , "environment" , "prod" ),
@@ -69,6 +72,11 @@ func TestAccProjectResource_prodEnvironment(t *testing.T) {
6972 })
7073}
7174
75+ // testProjectName generates a project name with the e2e prefix for hard deletion support.
76+ func testProjectName (suffix string ) string {
77+ return fmt .Sprintf ("%s-tf-%s-%d" , acctest .TestProjectNamePrefix , suffix , time .Now ().UnixNano ())
78+ }
79+
7280func testAccProjectResourceConfig (name , environment string ) string {
7381 return fmt .Sprintf (`
7482provider "ory" {}
0 commit comments