1515package google
1616
1717import (
18+ "fmt"
1819 "testing"
1920
2021 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -30,15 +31,27 @@ func TestAccHealthcareConsentStoreIamBindingGenerated(t *testing.T) {
3031
3132 vcrTest (t , resource.TestCase {
3233 PreCheck : func () { testAccPreCheck (t ) },
33- Providers : testAccProvidersOiCS ,
34+ Providers : testAccProviders ,
3435 Steps : []resource.TestStep {
3536 {
3637 Config : testAccHealthcareConsentStoreIamBinding_basicGenerated (context ),
3738 },
39+ {
40+ ResourceName : "google_healthcare_consent_store_iam_binding.foo" ,
41+ ImportStateId : fmt .Sprintf ("%s/consentStores/%s roles/viewer" , fmt .Sprintf ("projects/%s/locations/%s/datasets/tf-test-my-dataset%s" , getTestProjectFromEnv (), getTestRegionFromEnv (), context ["random_suffix" ]), fmt .Sprintf ("tf-test-my-consent-store%s" , context ["random_suffix" ])),
42+ ImportState : true ,
43+ ImportStateVerify : true ,
44+ },
3845 {
3946 // Test Iam Binding update
4047 Config : testAccHealthcareConsentStoreIamBinding_updateGenerated (context ),
4148 },
49+ {
50+ ResourceName : "google_healthcare_consent_store_iam_binding.foo" ,
51+ ImportStateId : fmt .Sprintf ("%s/consentStores/%s roles/viewer" , fmt .Sprintf ("projects/%s/locations/%s/datasets/tf-test-my-dataset%s" , getTestProjectFromEnv (), getTestRegionFromEnv (), context ["random_suffix" ]), fmt .Sprintf ("tf-test-my-consent-store%s" , context ["random_suffix" ])),
52+ ImportState : true ,
53+ ImportStateVerify : true ,
54+ },
4255 },
4356 })
4457}
@@ -53,12 +66,18 @@ func TestAccHealthcareConsentStoreIamMemberGenerated(t *testing.T) {
5366
5467 vcrTest (t , resource.TestCase {
5568 PreCheck : func () { testAccPreCheck (t ) },
56- Providers : testAccProvidersOiCS ,
69+ Providers : testAccProviders ,
5770 Steps : []resource.TestStep {
5871 {
5972 // Test Iam Member creation (no update for member, no need to test)
6073 Config : testAccHealthcareConsentStoreIamMember_basicGenerated (context ),
6174 },
75+ {
76+ ResourceName : "google_healthcare_consent_store_iam_member.foo" ,
77+ ImportStateId :
fmt .
Sprintf (
"%s/consentStores/%s roles/viewer user:[email protected] " ,
fmt .
Sprintf (
"projects/%s/locations/%s/datasets/tf-test-my-dataset%s" ,
getTestProjectFromEnv (),
getTestRegionFromEnv (),
context [
"random_suffix" ]),
fmt .
Sprintf (
"tf-test-my-consent-store%s" ,
context [
"random_suffix" ])),
78+ ImportState : true ,
79+ ImportStateVerify : true ,
80+ },
6281 },
6382 })
6483}
@@ -73,36 +92,43 @@ func TestAccHealthcareConsentStoreIamPolicyGenerated(t *testing.T) {
7392
7493 vcrTest (t , resource.TestCase {
7594 PreCheck : func () { testAccPreCheck (t ) },
76- Providers : testAccProvidersOiCS ,
95+ Providers : testAccProviders ,
7796 Steps : []resource.TestStep {
7897 {
7998 Config : testAccHealthcareConsentStoreIamPolicy_basicGenerated (context ),
8099 },
100+ {
101+ ResourceName : "google_healthcare_consent_store_iam_policy.foo" ,
102+ ImportStateId : fmt .Sprintf ("%s/consentStores/%s" , fmt .Sprintf ("projects/%s/locations/%s/datasets/tf-test-my-dataset%s" , getTestProjectFromEnv (), getTestRegionFromEnv (), context ["random_suffix" ]), fmt .Sprintf ("tf-test-my-consent-store%s" , context ["random_suffix" ])),
103+ ImportState : true ,
104+ ImportStateVerify : true ,
105+ },
81106 {
82107 Config : testAccHealthcareConsentStoreIamPolicy_emptyBinding (context ),
83108 },
109+ {
110+ ResourceName : "google_healthcare_consent_store_iam_policy.foo" ,
111+ ImportStateId : fmt .Sprintf ("%s/consentStores/%s" , fmt .Sprintf ("projects/%s/locations/%s/datasets/tf-test-my-dataset%s" , getTestProjectFromEnv (), getTestRegionFromEnv (), context ["random_suffix" ]), fmt .Sprintf ("tf-test-my-consent-store%s" , context ["random_suffix" ])),
112+ ImportState : true ,
113+ ImportStateVerify : true ,
114+ },
84115 },
85116 })
86117}
87118
88119func testAccHealthcareConsentStoreIamMember_basicGenerated (context map [string ]interface {}) string {
89120 return Nprintf (`
90121resource "google_healthcare_dataset" "dataset" {
91- provider = google-beta
92-
93122 location = "us-central1"
94123 name = "tf-test-my-dataset%{random_suffix}"
95124}
96125
97126resource "google_healthcare_consent_store" "my-consent" {
98- provider = google-beta
99-
100127 dataset = google_healthcare_dataset.dataset.id
101128 name = "tf-test-my-consent-store%{random_suffix}"
102129}
103130
104131resource "google_healthcare_consent_store_iam_member" "foo" {
105- provider = google-beta
106132 dataset = google_healthcare_consent_store.my-consent.dataset
107133 consent_store_id = google_healthcare_consent_store.my-consent.name
108134 role = "%{role}"
@@ -114,29 +140,23 @@ resource "google_healthcare_consent_store_iam_member" "foo" {
114140func testAccHealthcareConsentStoreIamPolicy_basicGenerated (context map [string ]interface {}) string {
115141 return Nprintf (`
116142resource "google_healthcare_dataset" "dataset" {
117- provider = google-beta
118-
119143 location = "us-central1"
120144 name = "tf-test-my-dataset%{random_suffix}"
121145}
122146
123147resource "google_healthcare_consent_store" "my-consent" {
124- provider = google-beta
125-
126148 dataset = google_healthcare_dataset.dataset.id
127149 name = "tf-test-my-consent-store%{random_suffix}"
128150}
129151
130152data "google_iam_policy" "foo" {
131- provider = google-beta
132153 binding {
133154 role = "%{role}"
134155 members = ["user:[email protected] "] 135156 }
136157}
137158
138159resource "google_healthcare_consent_store_iam_policy" "foo" {
139- provider = google-beta
140160 dataset = google_healthcare_consent_store.my-consent.dataset
141161 consent_store_id = google_healthcare_consent_store.my-consent.name
142162 policy_data = data.google_iam_policy.foo.policy_data
@@ -147,25 +167,19 @@ resource "google_healthcare_consent_store_iam_policy" "foo" {
147167func testAccHealthcareConsentStoreIamPolicy_emptyBinding (context map [string ]interface {}) string {
148168 return Nprintf (`
149169resource "google_healthcare_dataset" "dataset" {
150- provider = google-beta
151-
152170 location = "us-central1"
153171 name = "tf-test-my-dataset%{random_suffix}"
154172}
155173
156174resource "google_healthcare_consent_store" "my-consent" {
157- provider = google-beta
158-
159175 dataset = google_healthcare_dataset.dataset.id
160176 name = "tf-test-my-consent-store%{random_suffix}"
161177}
162178
163179data "google_iam_policy" "foo" {
164- provider = google-beta
165180}
166181
167182resource "google_healthcare_consent_store_iam_policy" "foo" {
168- provider = google-beta
169183 dataset = google_healthcare_consent_store.my-consent.dataset
170184 consent_store_id = google_healthcare_consent_store.my-consent.name
171185 policy_data = data.google_iam_policy.foo.policy_data
@@ -176,21 +190,16 @@ resource "google_healthcare_consent_store_iam_policy" "foo" {
176190func testAccHealthcareConsentStoreIamBinding_basicGenerated (context map [string ]interface {}) string {
177191 return Nprintf (`
178192resource "google_healthcare_dataset" "dataset" {
179- provider = google-beta
180-
181193 location = "us-central1"
182194 name = "tf-test-my-dataset%{random_suffix}"
183195}
184196
185197resource "google_healthcare_consent_store" "my-consent" {
186- provider = google-beta
187-
188198 dataset = google_healthcare_dataset.dataset.id
189199 name = "tf-test-my-consent-store%{random_suffix}"
190200}
191201
192202resource "google_healthcare_consent_store_iam_binding" "foo" {
193- provider = google-beta
194203 dataset = google_healthcare_consent_store.my-consent.dataset
195204 consent_store_id = google_healthcare_consent_store.my-consent.name
196205 role = "%{role}"
@@ -202,21 +211,16 @@ resource "google_healthcare_consent_store_iam_binding" "foo" {
202211func testAccHealthcareConsentStoreIamBinding_updateGenerated (context map [string ]interface {}) string {
203212 return Nprintf (`
204213resource "google_healthcare_dataset" "dataset" {
205- provider = google-beta
206-
207214 location = "us-central1"
208215 name = "tf-test-my-dataset%{random_suffix}"
209216}
210217
211218resource "google_healthcare_consent_store" "my-consent" {
212- provider = google-beta
213-
214219 dataset = google_healthcare_dataset.dataset.id
215220 name = "tf-test-my-consent-store%{random_suffix}"
216221}
217222
218223resource "google_healthcare_consent_store_iam_binding" "foo" {
219- provider = google-beta
220224 dataset = google_healthcare_consent_store.my-consent.dataset
221225 consent_store_id = google_healthcare_consent_store.my-consent.name
222226 role = "%{role}"
0 commit comments