|
| 1 | +package networkservices_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 5 | + "github.com/hashicorp/terraform-plugin-testing/plancheck" |
| 6 | + "github.com/hashicorp/terraform-provider-google/google/acctest" |
| 7 | + "testing" |
| 8 | +) |
| 9 | + |
| 10 | +func TestAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample(t *testing.T) { |
| 11 | + t.Parallel() |
| 12 | + |
| 13 | + context := map[string]interface{}{ |
| 14 | + "random_suffix": acctest.RandString(t, 10), |
| 15 | + } |
| 16 | + |
| 17 | + acctest.VcrTest(t, resource.TestCase{ |
| 18 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 19 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 20 | + CheckDestroy: testAccCheckNetworkServicesMulticastProducerAssociationDestroyProducer(t), |
| 21 | + Steps: []resource.TestStep{ |
| 22 | + { |
| 23 | + Config: testAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample_full(context), |
| 24 | + }, |
| 25 | + { |
| 26 | + ResourceName: "google_network_services_multicast_producer_association.mpa_test", |
| 27 | + ImportState: true, |
| 28 | + ImportStateVerify: true, |
| 29 | + ImportStateVerifyIgnore: []string{"labels", "location", "multicast_producer_association_id", "terraform_labels"}, |
| 30 | + }, |
| 31 | + { |
| 32 | + Config: testAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample_update(context), |
| 33 | + ConfigPlanChecks: resource.ConfigPlanChecks{ |
| 34 | + PreApply: []plancheck.PlanCheck{ |
| 35 | + plancheck.ExpectResourceAction("google_network_services_multicast_producer_association.mpa_test", plancheck.ResourceActionUpdate), |
| 36 | + }, |
| 37 | + }, |
| 38 | + }, |
| 39 | + { |
| 40 | + ResourceName: "google_network_services_multicast_producer_association.mpa_test", |
| 41 | + ImportState: true, |
| 42 | + ImportStateVerify: true, |
| 43 | + ImportStateVerifyIgnore: []string{"labels", "location", "multicast_producer_association_id", "terraform_labels"}, |
| 44 | + }, |
| 45 | + }, |
| 46 | + }) |
| 47 | +} |
| 48 | + |
| 49 | +func testAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample_full(context map[string]interface{}) string { |
| 50 | + return acctest.Nprintf(` |
| 51 | +resource "google_compute_network" "network" { |
| 52 | + name = "tf-test-test-network-mpa%{random_suffix}" |
| 53 | + auto_create_subnetworks = false |
| 54 | +} |
| 55 | +resource "google_network_services_multicast_domain" "multicast_domain" { |
| 56 | + multicast_domain_id = "tf-test-test-domain-mpa%{random_suffix}" |
| 57 | + location = "global" |
| 58 | + admin_network = google_compute_network.network.id |
| 59 | + connection_config { connection_type="SAME_VPC"} |
| 60 | + depends_on = [google_compute_network.network] |
| 61 | +} |
| 62 | +resource "google_network_services_multicast_domain_activation" "multicast_domain_activation" { |
| 63 | + multicast_domain_activation_id = "tf-test-test-domain-activation-mpa%{random_suffix}" |
| 64 | + location = "us-central1-b" |
| 65 | + multicast_domain = google_network_services_multicast_domain.multicast_domain.id |
| 66 | +} |
| 67 | +resource "google_network_services_multicast_producer_association" mpa_test { |
| 68 | + multicast_producer_association_id = "tf-test-test-producer-association-mpa%{random_suffix}" |
| 69 | + location = "us-central1-b" |
| 70 | + network = google_compute_network.network.id |
| 71 | + multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id |
| 72 | + depends_on = [google_compute_network.network] |
| 73 | +} |
| 74 | +`, context) |
| 75 | +} |
| 76 | + |
| 77 | +func testAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample_update(context map[string]interface{}) string { |
| 78 | + return acctest.Nprintf(` |
| 79 | +resource "google_compute_network" "network" { |
| 80 | + name = "tf-test-test-network-mpa%{random_suffix}" |
| 81 | + auto_create_subnetworks = false |
| 82 | +} |
| 83 | +resource "google_network_services_multicast_domain" "multicast_domain" { |
| 84 | + multicast_domain_id = "tf-test-test-domain-mpa%{random_suffix}" |
| 85 | + location = "global" |
| 86 | + admin_network = google_compute_network.network.id |
| 87 | + connection_config { connection_type="SAME_VPC"} |
| 88 | + depends_on = [google_compute_network.network] |
| 89 | +} |
| 90 | +resource "google_network_services_multicast_domain_activation" "multicast_domain_activation" { |
| 91 | + multicast_domain_activation_id = "tf-test-test-domain-activation-mpa%{random_suffix}" |
| 92 | + location = "us-central1-b" |
| 93 | + multicast_domain = google_network_services_multicast_domain.multicast_domain.id |
| 94 | +} |
| 95 | +resource "google_network_services_multicast_producer_association" mpa_test { |
| 96 | + multicast_producer_association_id = "tf-test-test-producer-association-mpa%{random_suffix}" |
| 97 | + location = "us-central1-b" |
| 98 | + description = "Updated description" |
| 99 | + labels = { |
| 100 | + fake_label = "label123" |
| 101 | + } |
| 102 | + network = google_compute_network.network.id |
| 103 | + multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id |
| 104 | + depends_on = [google_compute_network.network] |
| 105 | +} |
| 106 | +`, context) |
| 107 | +} |
0 commit comments