Skip to content

Commit d3fff61

Browse files
chore: Add acceptance tests for GCP on mongodbatlas_cloud_provider_access_authorization (#3653)
* Add acceptance test for GCP authorization resource * Remove attribute not needed for test * Add space on test * Address PR comment
1 parent 8cc5456 commit d3fff61

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

internal/service/cloudprovideraccess/resource_cloud_provider_access_authorization_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,44 @@ func TestAccCloudProviderAccessAuthorizationAzure_basic(t *testing.T) {
3838
)
3939
}
4040

41+
func TestAccCloudProviderAccessAuthorizationGCP_basic(t *testing.T) {
42+
var (
43+
resourceName = "mongodbatlas_cloud_provider_access_authorization.this"
44+
projectID = acc.ProjectIDExecution(t)
45+
)
46+
47+
resource.Test(t, resource.TestCase{
48+
PreCheck: func() { acc.PreCheckBasic(t) },
49+
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
50+
CheckDestroy: checkDestroy,
51+
Steps: []resource.TestStep{
52+
{
53+
Config: configAuthorizationGCP(projectID),
54+
Check: resource.ComposeAggregateTestCheckFunc(
55+
checkExists(resourceName),
56+
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
57+
resource.TestCheckResourceAttrSet(resourceName, "role_id"),
58+
resource.TestCheckResourceAttrSet(resourceName, "gcp.0.service_account_for_atlas"),
59+
),
60+
},
61+
},
62+
})
63+
}
64+
65+
func configAuthorizationGCP(projectID string) string {
66+
return fmt.Sprintf(`
67+
resource "mongodbatlas_cloud_provider_access_setup" "gcp_setup" {
68+
project_id = %[1]q
69+
provider_name = "GCP"
70+
}
71+
72+
resource "mongodbatlas_cloud_provider_access_authorization" "this" {
73+
project_id = mongodbatlas_cloud_provider_access_setup.gcp_setup.project_id
74+
role_id = mongodbatlas_cloud_provider_access_setup.gcp_setup.role_id
75+
}
76+
`, projectID)
77+
}
78+
4179
func basicAuthorizationTestCase(tb testing.TB) *resource.TestCase {
4280
tb.Helper()
4381

0 commit comments

Comments
 (0)