From 8e19c1f362b81da69201b69a9ef1fe8fb925c050 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Tue, 24 Sep 2019 09:58:55 -0700 Subject: [PATCH] Add empty binding test to generated --- .../base_configs/iam_test_file.go.erb | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/templates/terraform/examples/base_configs/iam_test_file.go.erb b/templates/terraform/examples/base_configs/iam_test_file.go.erb index 743dfb1c5e20..9c5b94581a48 100644 --- a/templates/terraform/examples/base_configs/iam_test_file.go.erb +++ b/templates/terraform/examples/base_configs/iam_test_file.go.erb @@ -116,6 +116,15 @@ func TestAcc<%= resource_name -%>IamPolicyGenerated(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + Config: testAcc<%= resource_name -%>IamPolicy_emptyBinding(context), + }, + { + ResourceName: "<%= resource_ns_iam -%>_policy.foo", + ImportStateId: fmt.Sprintf("<%= import_url -%>"<% unless import_qualifiers.empty? -%>, <% end -%><%= import_qualifiers.join(', ') -%>, <%= example.primary_resource_name -%>), + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -150,6 +159,20 @@ resource "<%= resource_ns_iam -%>_policy" "foo" { `, context) } +func testAcc<%= resource_name -%>IamPolicy_emptyBinding(context map[string]interface{}) string { + return Nprintf(` +<%= example.config_test_body -%> + +data "google_iam_policy" "foo" { +} + +resource "<%= resource_ns_iam -%>_policy" "foo" { +<%= lines(compile('templates/terraform/iam/iam_attributes.go.erb')) -%> + policy_data = "${data.google_iam_policy.foo.policy_data}" +} +`, context) +} + func testAcc<%= resource_name -%>IamBinding_basicGenerated(context map[string]interface{}) string { return Nprintf(` <%= example.config_test_body -%>