From 3cf834486115324bbeb28899f91cf293bb5dabb2 Mon Sep 17 00:00:00 2001 From: Bianca Del Carretto Date: Wed, 11 Sep 2024 16:57:54 +0200 Subject: [PATCH] fix(test): adjust resource account test --- .../resource_account_resource_test.go | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/provider/resource_account_resource_test.go b/internal/provider/resource_account_resource_test.go index 93f41cf..502a0a5 100644 --- a/internal/provider/resource_account_resource_test.go +++ b/internal/provider/resource_account_resource_test.go @@ -14,8 +14,8 @@ import ( ) func TestAccResourceAccountResource(t *testing.T) { - id := fmt.Sprintf("gcp-test-%d", time.Now().UnixNano()) - email := fmt.Sprintf("gpc-myemail-%d@email.com", time.Now().UnixNano()) + id := fmt.Sprintf("aws-test-%d", time.Now().UnixNano()) + role := fmt.Sprintf("arn:aws:iam::0000000:role/test-role-%d", time.Now().UnixNano()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -23,24 +23,24 @@ func TestAccResourceAccountResource(t *testing.T) { Steps: []resource.TestStep{ // Create and Read testing { - Config: testAccResourceAccountResource(id, "gcp-test-1", email), + Config: testAccResourceAccountResource(id, "aws-test-1", role), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("humanitec_resource_account.gcp_test", "id", id), - resource.TestCheckResourceAttr("humanitec_resource_account.gcp_test", "name", "gcp-test-1"), + resource.TestCheckResourceAttr("humanitec_resource_account.aws_test", "id", id), + resource.TestCheckResourceAttr("humanitec_resource_account.aws_test", "name", "aws-test-1"), ), }, // ImportState testing { - ResourceName: "humanitec_resource_account.gcp_test", + ResourceName: "humanitec_resource_account.aws_test", ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"credentials"}, }, // Update and Read testing { - Config: testAccResourceAccountResource(id, "gcp-test-2", email), + Config: testAccResourceAccountResource(id, "aws-test-2", role), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("humanitec_resource_account.gcp_test", "name", "gcp-test-2"), + resource.TestCheckResourceAttr("humanitec_resource_account.aws_test", "name", "aws-test-2"), ), }, // Delete testing automatically occurs in TestCase @@ -51,8 +51,8 @@ func TestAccResourceAccountResource(t *testing.T) { func TestAccResourceAccountResource_DeletedManually(t *testing.T) { assert := assert.New(t) ctx := context.Background() - id := fmt.Sprintf("gcp-test-%d", time.Now().UnixNano()) - email := fmt.Sprintf("gpc-myemail-%d@email.com", time.Now().UnixNano()) + id := fmt.Sprintf("aws-test-%d", time.Now().UnixNano()) + role := fmt.Sprintf("arn:aws:iam::0000000:role/test-role-%d", time.Now().UnixNano()) orgID := os.Getenv("HUMANITEC_ORG") token := os.Getenv("HUMANITEC_TOKEN") @@ -74,9 +74,9 @@ func TestAccResourceAccountResource_DeletedManually(t *testing.T) { ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ { - Config: testAccResourceAccountResource(id, "gcp-test-2", email), + Config: testAccResourceAccountResource(id, "aws-test-2", role), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("humanitec_resource_account.gcp_test", "id", id), + resource.TestCheckResourceAttr("humanitec_resource_account.aws_test", "id", id), func(_ *terraform.State) error { // Manually delete the resource account via the API resp, err := client.DeleteResourceAccountWithResponse(ctx, orgID, id) @@ -97,16 +97,16 @@ func TestAccResourceAccountResource_DeletedManually(t *testing.T) { }) } -func testAccResourceAccountResource(id, name, email string) string { +func testAccResourceAccountResource(id, name, role string) string { return fmt.Sprintf(` -resource "humanitec_resource_account" "gcp_test" { +resource "humanitec_resource_account" "aws_test" { id = "%s" name = "%s" - type = "gcp" + type = "aws-role" credentials = jsonencode({ - client_email = "%s" - private_key = "mykey" + aws_role = "%s" + external_id = "test_external_id" }) } -`, id, name, email) +`, id, name, role) }