-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecated-->removed event notification config (#2390)
* deprecated-->removed event notification config * remove singular config from tests/docs * pluralize * Update third_party/terraform/tests/resource_cloudiot_registry_test.go Co-Authored-By: Riley Karson <[email protected]>
- Loading branch information
1 parent
0a27c9c
commit f62ad50
Showing
3 changed files
with
31 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,7 +116,7 @@ func TestAccCloudIoTRegistry_update(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccCloudIoTRegistry_eventNotificationConfigDeprecatedSingleToPlural(t *testing.T) { | ||
func TestAccCloudIoTRegistry_eventNotificationConfigsSingle(t *testing.T) { | ||
t.Parallel() | ||
|
||
registryName := fmt.Sprintf("tf-registry-test-%s", acctest.RandString(10)) | ||
|
@@ -128,29 +128,18 @@ func TestAccCloudIoTRegistry_eventNotificationConfigDeprecatedSingleToPlural(t * | |
CheckDestroy: testAccCheckCloudIoTRegistryDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
// Use deprecated field (event_notification_config) to create | ||
Config: testAccCloudIoTRegistry_singleEventNotificationConfig(topic, registryName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr( | ||
"google_cloudiot_registry.foobar", "event_notification_configs.#", "1"), | ||
), | ||
Config: testAccCloudIoTRegistry_singleEventNotificationConfigs(topic, registryName), | ||
}, | ||
{ | ||
ResourceName: "google_cloudiot_registry.foobar", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
// Use new field (event_notification_configs) to see if plan changed | ||
Config: testAccCloudIoTRegistry_pluralEventNotificationConfigs(topic, registryName), | ||
PlanOnly: true, | ||
ExpectNonEmptyPlan: false, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccCloudIoTRegistry_eventNotificationConfigMultiple(t *testing.T) { | ||
func TestAccCloudIoTRegistry_eventNotificationConfigsMultiple(t *testing.T) { | ||
t.Parallel() | ||
|
||
registryName := fmt.Sprintf("tf-registry-test-%s", acctest.RandString(10)) | ||
|
@@ -173,40 +162,6 @@ func TestAccCloudIoTRegistry_eventNotificationConfigMultiple(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccCloudIoTRegistry_eventNotificationConfigPluralToDeprecatedSingle(t *testing.T) { | ||
t.Parallel() | ||
|
||
registryName := fmt.Sprintf("tf-registry-test-%s", acctest.RandString(10)) | ||
topic := fmt.Sprintf("tf-registry-test-%s", acctest.RandString(10)) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckCloudIoTRegistryDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
// Use new field (event_notification_configs) to create | ||
Config: testAccCloudIoTRegistry_pluralEventNotificationConfigs(topic, registryName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr( | ||
"google_cloudiot_registry.foobar", "event_notification_configs.#", "1"), | ||
), | ||
}, | ||
{ | ||
ResourceName: "google_cloudiot_registry.foobar", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
// Use old field (event_notification_config) to see if plan changed | ||
Config: testAccCloudIoTRegistry_singleEventNotificationConfig(topic, registryName), | ||
PlanOnly: true, | ||
ExpectNonEmptyPlan: false, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckCloudIoTRegistryDestroy(s *terraform.State) error { | ||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type != "google_cloudiot_registry" { | ||
|
@@ -322,6 +277,30 @@ resource "google_cloudiot_registry" "foobar" { | |
`, topic, registryName) | ||
} | ||
|
||
func testAccCloudIoTRegistry_singleEventNotificationConfigs(topic, registryName string) string { | ||
return fmt.Sprintf(` | ||
resource "google_project_iam_binding" "cloud-iot-iam-binding" { | ||
members = ["serviceAccount:[email protected]"] | ||
role = "roles/pubsub.publisher" | ||
} | ||
resource "google_pubsub_topic" "event-topic-1" { | ||
name = "%s" | ||
} | ||
resource "google_cloudiot_registry" "foobar" { | ||
depends_on = ["google_project_iam_binding.cloud-iot-iam-binding"] | ||
name = "%s" | ||
event_notification_configs { | ||
pubsub_topic_name = "${google_pubsub_topic.event-topic-1.id}" | ||
subfolder_matches = "" | ||
} | ||
} | ||
`, topic, registryName) | ||
} | ||
|
||
func testAccCloudIoTRegistry_multipleEventNotificationConfigs(topic, registryName string) string { | ||
return fmt.Sprintf(` | ||
resource "google_project_iam_binding" "cloud-iot-iam-binding" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters