Skip to content

Commit d8ab38d

Browse files
lisajianyerniyazN
authored andcommitted
Add tests for force deletion (GoogleCloudPlatform#13219)
1 parent d912a5c commit d8ab38d

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

mmv1/products/firebasedataconnect/Service.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ examples:
3535
service_id: example-service
3636
test_env_vars:
3737
project_id: 'PROJECT_NAME'
38+
- name: firebasedataconnect_service_with_force_deletion
39+
primary_resource_id: default
40+
vars:
41+
service_id: example-service
42+
test_env_vars:
43+
project_id: 'PROJECT_NAME'
44+
ignore_read_extra:
45+
- 'deletion_policy'
3846
autogen_async: true
3947
async:
4048
operation:

mmv1/templates/terraform/examples/firebasedataconnect_service_basic.tf.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resource "google_project_service" "fdc" {
55
disable_on_destroy = false
66
}
77

8-
# Create an FDC service
8+
# Create a Firebase Data Connect service
99
resource "google_firebase_data_connect_service" "default" {
1010
project = "{{index $.TestEnvVars "project_id"}}"
1111
location = "us-central1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Enable Firebase Data Connect API
2+
resource "google_project_service" "fdc" {
3+
project = "{{index $.TestEnvVars "project_id"}}"
4+
service = "firebasedataconnect.googleapis.com"
5+
disable_on_destroy = false
6+
}
7+
8+
# Create a Firebase Data Connect service
9+
resource "google_firebase_data_connect_service" "default" {
10+
project = "{{index $.TestEnvVars "project_id"}}"
11+
location = "us-central1"
12+
service_id = "{{index $.Vars "service_id"}}"
13+
deletion_policy = "FORCE"
14+
15+
depends_on = [google_project_service.fdc]
16+
}

mmv1/third_party/terraform/services/firebasedataconnect/resource_firebase_data_connect_service_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ func TestAccFirebaseDataConnectService_Update(t *testing.T) {
2727
CheckDestroy: testAccCheckFirebaseDataConnectServiceDestroyProducer(t),
2828
Steps: []resource.TestStep{
2929
{
30-
Config: testAccFirebaseDataConnectService_update(context, "Original display name"),
30+
Config: testAccFirebaseDataConnectService_update(context, "Original display name", "DEFAULT"),
3131
},
3232
{
3333
ResourceName: "google_firebase_data_connect_service.default",
3434
ImportState: true,
3535
ImportStateVerify: true,
36-
ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "service_id", "terraform_labels"},
36+
ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "service_id", "terraform_labels", "deletion_policy"},
3737
},
3838
{
39-
Config: testAccFirebaseDataConnectService_update(context, "Updated display name"),
39+
Config: testAccFirebaseDataConnectService_update(context, "Updated display name", "FORCE"),
4040
ConfigPlanChecks: resource.ConfigPlanChecks{
4141
PreApply: []plancheck.PlanCheck{
4242
plancheck.ExpectResourceAction("google_firebase_data_connect_service.default", plancheck.ResourceActionUpdate),
@@ -47,15 +47,15 @@ func TestAccFirebaseDataConnectService_Update(t *testing.T) {
4747
ResourceName: "google_firebase_data_connect_service.default",
4848
ImportState: true,
4949
ImportStateVerify: true,
50-
ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "service_id", "terraform_labels"},
50+
ImportStateVerifyIgnore: []string{"annotations", "labels", "location", "service_id", "terraform_labels", "deletion_policy"},
5151
},
5252
},
5353
})
5454
}
5555

56-
// TODO(b/394642094): Cover force deletion once it's supported
57-
func testAccFirebaseDataConnectService_update(context map[string]interface{}, display_name string) string {
56+
func testAccFirebaseDataConnectService_update(context map[string]interface{}, display_name string, deletion_policy string) string {
5857
context["display_name"] = display_name
58+
context["deletion_policy"] = deletion_policy
5959
return acctest.Nprintf(`
6060
# Enable Firebase Data Connect API
6161
resource "google_project_service" "fdc" {
@@ -70,6 +70,7 @@ resource "google_firebase_data_connect_service" "default" {
7070
location = "us-central1"
7171
service_id = "tf-fdc-%{random_suffix}"
7272
display_name = "%{display_name}"
73+
deletion_policy = "%{deletion_policy}"
7374
7475
depends_on = [google_project_service.fdc]
7576
}

0 commit comments

Comments
 (0)