Skip to content

Commit

Permalink
Use correct resource checks
Browse files Browse the repository at this point in the history
  • Loading branch information
matty271828 committed Dec 7, 2023
1 parent 173da95 commit d981b77
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions internal/resources/acceptance_tests/user_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ import (
)

func TestAccUserResource(t *testing.T) {
resourceName := "acc_user" + cfg.GenerateRandomResourceName()
resourceName := "acc_user_" + cfg.GenerateRandomResourceName()
resourceReference := "couchbase-capella_user." + resourceName
projectResourceName := "acc_project_" + cfg.GenerateRandomResourceName()
projectResourceReference := "couchbase-capella_project." + projectResourceName

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { cfg.TestAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
ProtoV6ProviderFactories: cfg.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and Read
{
Config: testAccUserResourceConfig(cfg.Cfg, resourceName, projectResourceName, projectResourceReference),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceReference, "name", "acc_test_user_name"),
resource.TestCheckResourceAttr(resourceReference, "email", "[email protected]"),
resource.TestCheckResourceAttr(resourceReference, "resources", "acc_test_resources"),
resource.TestCheckResourceAttr(resourceReference, "organization_roles.0", "organizationOwner"),
),
},
// Import state
Expand All @@ -45,9 +45,9 @@ func TestAccUserResource(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceReference, "name", "acc_test_user_name"),
resource.TestCheckResourceAttr(resourceReference, "email", "[email protected]"),
resource.TestCheckResourceAttr(resourceReference, "organization_roles.0", "organizationMember"),
resource.TestCheckResourceAttr(resourceReference, "resources.0.type", "project"),
resource.TestCheckResourceAttr(resourceReference, "resources.0.roles.0", "projectViewer"),
resource.TestCheckResourceAttr(resourceReference, "resources", "acc_test_resources"),
),
},
// NOTE: No delete case is provided - this occurs automatically
Expand Down Expand Up @@ -139,11 +139,7 @@ func TestAccUserResourceResourceNotFound(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceReference, "name", "acc_test_user_name"),
resource.TestCheckResourceAttr(resourceReference, "email", "acc_test_email"),
resource.TestCheckResourceAttr(
resourceReference, "organization_roles", "acc_test_organization_roles",
),
resource.TestCheckResourceAttr(resourceReference, "resources", "acc_test_resources"),

resource.TestCheckResourceAttr(resourceReference, "organization_roles.0", "organizationOwner"),
// Delete the user from the server and wait until deletion is successful
testAccDeleteUserResource(resourceReference),
),
Expand All @@ -157,9 +153,9 @@ func TestAccUserResourceResourceNotFound(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceReference, "name", "acc_test_user_name"),
resource.TestCheckResourceAttr(resourceReference, "email", "acc_test_email"),
resource.TestCheckResourceAttr(resourceReference, "organization_roles.0", "organizationMember"),
resource.TestCheckResourceAttr(resourceReference, "resources.0.type", "project"),
resource.TestCheckResourceAttr(resourceReference, "resources.0.roles.0", "projectViewer"),
resource.TestCheckResourceAttr(resourceReference, "resources", "acc_test_resources"),
),
},
},
Expand Down

0 comments on commit d981b77

Please sign in to comment.