forked from hashicorp/terraform-provider-google
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_source_google_logging_project_cmek_settings_test.go
51 lines (44 loc) · 1.43 KB
/
data_source_google_logging_project_cmek_settings_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package google
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccLoggingProjectCmekSettings_basic(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"project_name": "tf-test-" + randString(t, 10),
"org_id": getTestOrgFromEnv(t),
"billing_account": getTestBillingAccountFromEnv(t),
}
resourceName := "data.google_logging_project_cmek_settings.cmek_settings"
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccLoggingProjectCmekSettings_basic(context),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
resourceName, "id", fmt.Sprintf("projects/%s/cmekSettings", context["project_name"])),
resource.TestCheckResourceAttr(
resourceName, "name", fmt.Sprintf("projects/%s/cmekSettings", context["project_name"])),
resource.TestCheckResourceAttrSet(resourceName, "service_account_id"),
),
},
},
})
}
func testAccLoggingProjectCmekSettings_basic(context map[string]interface{}) string {
return Nprintf(`
resource "google_project" "default" {
project_id = "%{project_name}"
name = "%{project_name}"
org_id = "%{org_id}"
billing_account = "%{billing_account}"
}
data "google_logging_project_cmek_settings" "cmek_settings" {
project = google_project.default.name
}
`, context)
}