@@ -8,8 +8,48 @@ import (
88 "testing"
99
1010 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
11+ "github.com/hashicorp/terraform-plugin-testing/plancheck"
1112)
1213
14+ func TestAccComputeGlobalAddress_update (t * testing.T ) {
15+ t .Parallel ()
16+
17+ context := map [string ]interface {}{
18+ "random_suffix" : acctest .RandString (t , 10 ),
19+ }
20+
21+ acctest .VcrTest (t , resource.TestCase {
22+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
23+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
24+ CheckDestroy : testAccCheckComputeGlobalAddressDestroyProducer (t ),
25+ Steps : []resource.TestStep {
26+ {
27+ Config : testAccComputeGlobalAddress_update1 (context ),
28+ },
29+ {
30+ ResourceName : "google_compute_global_address.foobar" ,
31+ ImportState : true ,
32+ ImportStateVerify : true ,
33+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
34+ },
35+ {
36+ Config : testAccComputeGlobalAddress_update2 (context ),
37+ ConfigPlanChecks : resource.ConfigPlanChecks {
38+ PreApply : []plancheck.PlanCheck {
39+ acctest .ExpectNoDelete (),
40+ },
41+ },
42+ },
43+ {
44+ ResourceName : "google_compute_global_address.foobar" ,
45+ ImportState : true ,
46+ ImportStateVerify : true ,
47+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
48+ },
49+ },
50+ })
51+ }
52+
1353func TestAccComputeGlobalAddress_ipv6 (t * testing.T ) {
1454 t .Parallel ()
1555
@@ -76,3 +116,47 @@ resource "google_compute_global_address" "foobar" {
76116}
77117` , networkName , addressName )
78118}
119+
120+ func testAccComputeGlobalAddress_update1 (context map [string ]interface {}) string {
121+ return acctest .Nprintf (`
122+ resource "google_compute_network" "foobar" {
123+ name = "tf-test-address-%{random_suffix}"
124+ }
125+
126+ resource "google_compute_global_address" "foobar" {
127+ address = "172.20.181.0"
128+ description = "Description"
129+ name = "tf-test-address-%{random_suffix}"
130+ labels = {
131+ foo = "bar"
132+ }
133+ ip_version = "IPV4"
134+ prefix_length = 24
135+ address_type = "INTERNAL"
136+ purpose = "VPC_PEERING"
137+ network = google_compute_network.foobar.self_link
138+ }
139+ ` , context )
140+ }
141+
142+ func testAccComputeGlobalAddress_update2 (context map [string ]interface {}) string {
143+ return acctest .Nprintf (`
144+ resource "google_compute_network" "foobar" {
145+ name = "tf-test-address-%{random_suffix}"
146+ }
147+
148+ resource "google_compute_global_address" "foobar" {
149+ address = "172.20.181.0"
150+ description = "Description"
151+ name = "tf-test-address-%{random_suffix}"
152+ labels = {
153+ foo = "baz"
154+ }
155+ ip_version = "IPV4"
156+ prefix_length = 24
157+ address_type = "INTERNAL"
158+ purpose = "VPC_PEERING"
159+ network = google_compute_network.foobar.self_link
160+ }
161+ ` , context )
162+ }
0 commit comments