@@ -112,7 +112,6 @@ func TestAccComputeNetwork_routingModeAndUpdate(t *testing.T) {
112
112
})
113
113
}
114
114
115
- {{ if ne $.TargetVersionName `ga` -}}
116
115
func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
117
116
t.Parallel()
118
117
@@ -122,15 +121,15 @@ func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
122
121
123
122
acctest.VcrTest(t, resource.TestCase{
124
123
PreCheck: func() { acctest.AccTestPreCheck(t) },
125
- ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories (t),
124
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories (t),
126
125
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
127
126
Steps: []resource.TestStep{
128
127
{
129
128
Config: testAccComputeNetwork_best_bgp_path_selection_mode(networkName, "LEGACY"),
130
129
Check: resource.ComposeTestCheckFunc(
131
130
testAccCheckComputeNetworkExists(
132
131
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
133
- testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network , "LEGACY"),
132
+ resource.TestCheckResourceAttr( "google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_best_path_selection_mode" , "LEGACY"),
134
133
),
135
134
},
136
135
// Test updating the best bgp path selection field (only updatable field).
@@ -139,7 +138,7 @@ func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
139
138
Check: resource.ComposeTestCheckFunc(
140
139
testAccCheckComputeNetworkExists(
141
140
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
142
- testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network , "STANDARD"),
141
+ resource.TestCheckResourceAttr( "google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_best_path_selection_mode" , "STANDARD"),
143
142
),
144
143
},
145
144
},
@@ -157,16 +156,15 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {
157
156
158
157
acctest.VcrTest(t, resource.TestCase{
159
158
PreCheck: func() { acctest.AccTestPreCheck(t) },
160
- ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories (t),
159
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories (t),
161
160
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
162
161
Steps: []resource.TestStep{
163
162
{
164
163
Config: testAccComputeNetwork_bgp_always_compare_med(networkName, false),
165
164
Check: resource.ComposeTestCheckFunc(
166
165
testAccCheckComputeNetworkExists(
167
166
t, "google_compute_network.acc_network_bgp_always_compare_med", &network),
168
- testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
169
- t, "google_compute_network.acc_network_bgp_always_compare_med", &network, false),
167
+ resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_always_compare_med", "bgp_always_compare_med", "false"),
170
168
),
171
169
},
172
170
// Test updating the bgpAlwaysCompareMed field (only updatable field).
@@ -175,8 +173,7 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {
175
173
Check: resource.ComposeTestCheckFunc(
176
174
testAccCheckComputeNetworkExists(
177
175
t, "google_compute_network.acc_network_bgp_always_compare_med", &network),
178
- testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
179
- t, "google_compute_network.acc_network_bgp_always_compare_med", &network, true),
176
+ resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_always_compare_med", "bgp_always_compare_med", "true"),
180
177
),
181
178
},
182
179
},
@@ -193,16 +190,15 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {
193
190
194
191
acctest.VcrTest(t, resource.TestCase{
195
192
PreCheck: func() { acctest.AccTestPreCheck(t) },
196
- ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories (t),
193
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories (t),
197
194
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
198
195
Steps: []resource.TestStep{
199
196
{
200
197
Config: testAccComputeNetwork_bgp_inter_region_cost(networkName, "DEFAULT"),
201
198
Check: resource.ComposeTestCheckFunc(
202
199
testAccCheckComputeNetworkExists(
203
200
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network),
204
- testAccCheckComputeNetworkHasBgpInterRegionCost(
205
- t, "google_compute_network.acc_network_bgp_inter_region_cost", &network, "DEFAULT"),
201
+ resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_inter_region_cost", "bgp_inter_region_cost", "DEFAULT"),
206
202
),
207
203
},
208
204
// Test updating the bgpInterRegionCost field (only updatable field).
@@ -211,14 +207,14 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {
211
207
Check: resource.ComposeTestCheckFunc(
212
208
testAccCheckComputeNetworkExists(
213
209
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network),
214
- testAccCheckComputeNetworkHasBgpInterRegionCost(
215
- t, "google_compute_network.acc_network_bgp_inter_region_cost", &network, "ADD_COST_TO_MED"),
210
+ resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_inter_region_cost", "bgp_inter_region_cost", "ADD_COST_TO_MED"),
216
211
),
217
212
},
218
213
},
219
214
})
220
215
}
221
216
217
+ {{ if ne $.TargetVersionName `ga` -}}
222
218
func TestAccComputeNetwork_networkProfile(t *testing.T) {
223
219
t.Parallel()
224
220
@@ -303,7 +299,6 @@ func TestAccComputeNetwork_default_routing_mode(t *testing.T) {
303
299
})
304
300
}
305
301
306
- {{ if ne $.TargetVersionName `ga` -}}
307
302
func TestAccComputeNetwork_default_bgp_best_path_selection_mode(t *testing.T) {
308
303
t.Parallel()
309
304
@@ -315,15 +310,15 @@ func TestAccComputeNetwork_default_bgp_best_path_selection_mode(t *testing.T) {
315
310
316
311
acctest.VcrTest(t, resource.TestCase{
317
312
PreCheck: func() { acctest.AccTestPreCheck(t) },
318
- ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories (t),
313
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories (t),
319
314
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
320
315
Steps: []resource.TestStep{
321
316
{
322
- Config: testAccComputeBetaNetwork_basic (networkName),
317
+ Config: testAccComputeNetwork_basic (networkName),
323
318
Check: resource.ComposeTestCheckFunc(
324
319
testAccCheckComputeNetworkExists(
325
320
t, "google_compute_network.bar", &network),
326
- testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.bar", &network , expectedBgpBestPathSelection),
321
+ resource.TestCheckResourceAttr( "google_compute_network.bar", "bgp_best_path_selection_mode" , expectedBgpBestPathSelection),
327
322
),
328
323
},
329
324
},
@@ -338,26 +333,24 @@ func TestAccComputeNetwork_default_bgp_always_compare_med(t *testing.T) {
338
333
suffixName := acctest.RandString(t, 10)
339
334
networkName := fmt.Sprintf("tf-test-bgp-always-compare-med-default-routes-%s", suffixName)
340
335
341
- expectedBgpAlwaysCompareMed := false
336
+ expectedBgpAlwaysCompareMed := " false"
342
337
343
338
acctest.VcrTest(t, resource.TestCase{
344
339
PreCheck: func() { acctest.AccTestPreCheck(t) },
345
- ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories (t),
340
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories (t),
346
341
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
347
342
Steps: []resource.TestStep{
348
343
{
349
344
Config: testAccComputeNetwork_best_bgp_path_selection_mode(networkName, "STANDARD"),
350
345
Check: resource.ComposeTestCheckFunc(
351
346
testAccCheckComputeNetworkExists(
352
347
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
353
- testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
354
- t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, expectedBgpAlwaysCompareMed),
348
+ resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_always_compare_med", expectedBgpAlwaysCompareMed),
355
349
),
356
350
},
357
351
},
358
352
})
359
353
}
360
- {{- end }}
361
354
362
355
func TestAccComputeNetwork_networkDeleteDefaultRoute(t *testing.T) {
363
356
t.Parallel()
@@ -564,94 +557,8 @@ func testAccCheckComputeNetworkHasRoutingMode(t *testing.T, n string, network *c
564
557
}
565
558
}
566
559
567
- {{ if ne $.TargetVersionName `ga` -}}
568
- func testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t *testing.T, n string, network *compute.Network, bgpBestPathSelectionMode string) resource.TestCheckFunc {
569
- return func(s *terraform.State) error {
570
- config := acctest.GoogleProviderConfig(t)
571
-
572
- rs, ok := s.RootModule().Resources[n]
573
- if !ok {
574
- return fmt.Errorf("Not found: %s", n)
575
- }
576
-
577
- if rs.Primary.Attributes["bgp_always_compare_med"] == "" {
578
- return fmt.Errorf("BGP always compare med not found on resource")
579
- }
580
-
581
- found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
582
- config.Project, network.Name).Do()
583
- if err != nil {
584
- return err
585
- }
586
-
587
- foundBgpBestPathSelectionMode := found.RoutingConfig.BgpBestPathSelectionMode
588
-
589
- if bgpBestPathSelectionMode != foundBgpBestPathSelectionMode {
590
- return fmt.Errorf("Expected BGP always compare med %s to match actual BGP always compare med %s", bgpBestPathSelectionMode, foundBgpBestPathSelectionMode)
591
- }
592
-
593
- return nil
594
- }
595
- }
596
-
597
- func testAccCheckComputeNetworkHasBgpAlwaysCompareMed(t *testing.T, n string, network *compute.Network, bgpAlwaysCompareMed bool) resource.TestCheckFunc {
598
- return func(s *terraform.State) error {
599
- config := acctest.GoogleProviderConfig(t)
600
-
601
- rs, ok := s.RootModule().Resources[n]
602
- if !ok {
603
- return fmt.Errorf("Not found: %s", n)
604
- }
605
-
606
- if rs.Primary.Attributes["bgp_always_compare_med"] == "" {
607
- return fmt.Errorf("BGP always compare med not found on resource")
608
- }
609
-
610
- found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
611
- config.Project, network.Name).Do()
612
- if err != nil {
613
- return err
614
- }
615
-
616
- foundBgpAlwaysCompareMed := found.RoutingConfig.BgpAlwaysCompareMed
617
-
618
- if foundBgpAlwaysCompareMed != bgpAlwaysCompareMed {
619
- return fmt.Errorf("Expected BGP always compare med %t to match actual BGP always compare med %t", bgpAlwaysCompareMed, foundBgpAlwaysCompareMed)
620
- }
621
-
622
- return nil
623
- }
624
- }
625
-
626
- func testAccCheckComputeNetworkHasBgpInterRegionCost(t *testing.T, n string, network *compute.Network, bgpInterRegionCost string) resource.TestCheckFunc {
627
- return func(s *terraform.State) error {
628
- config := acctest.GoogleProviderConfig(t)
629
-
630
- rs, ok := s.RootModule().Resources[n]
631
- if !ok {
632
- return fmt.Errorf("Not found: %s", n)
633
- }
634
-
635
- if rs.Primary.Attributes["bgp_inter_region_cost"] == "" {
636
- return fmt.Errorf("BGP inter region cost not found on resource")
637
- }
638
-
639
- found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
640
- config.Project, network.Name).Do()
641
- if err != nil {
642
- return err
643
- }
644
-
645
- foundBgpInterRegionCost := found.RoutingConfig.BgpInterRegionCost
646
-
647
- if foundBgpInterRegionCost != bgpInterRegionCost {
648
- return fmt.Errorf("Expected BGP always compare med %s to match actual BGP always compare med %s", bgpInterRegionCost, foundBgpInterRegionCost)
649
- }
650
-
651
- return nil
652
- }
653
- }
654
560
561
+ {{ if ne $.TargetVersionName `ga` -}}
655
562
func testAccCheckComputeNetworkHasNetworkProfile(t *testing.T, n string, network *compute.Network, networkProfile string) resource.TestCheckFunc {
656
563
return func(s *terraform.State) error {
657
564
config := acctest.GoogleProviderConfig(t)
@@ -747,21 +654,10 @@ resource "google_compute_network" "acc_network_routing_mode" {
747
654
`, networkName, routingMode)
748
655
}
749
656
750
- {{ if ne $.TargetVersionName `ga` -}}
751
- func testAccComputeBetaNetwork_basic(networkName string) string {
752
- return fmt.Sprintf(`
753
- resource "google_compute_network" "bar" {
754
- provider = google-beta
755
- name = "%s"
756
- auto_create_subnetworks = true
757
- }
758
- `, networkName)
759
- }
760
657
761
658
func testAccComputeNetwork_best_bgp_path_selection_mode(networkName, bgpBestPathSelection string) string {
762
659
return fmt.Sprintf(`
763
660
resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
764
- provider = google-beta
765
661
name = "%s"
766
662
routing_mode = "GLOBAL"
767
663
bgp_best_path_selection_mode = "%s"
@@ -772,7 +668,6 @@ resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
772
668
func testAccComputeNetwork_bgp_always_compare_med(networkName string, bgpAlwaysCompareMed bool) string {
773
669
return fmt.Sprintf(`
774
670
resource "google_compute_network" "acc_network_bgp_always_compare_med" {
775
- provider = google-beta
776
671
name = "%s"
777
672
routing_mode = "GLOBAL"
778
673
bgp_best_path_selection_mode = "STANDARD"
@@ -784,7 +679,6 @@ resource "google_compute_network" "acc_network_bgp_always_compare_med" {
784
679
func testAccComputeNetwork_bgp_inter_region_cost(networkName, bgpInterRegionCost string) string {
785
680
return fmt.Sprintf(`
786
681
resource "google_compute_network" "acc_network_bgp_inter_region_cost" {
787
- provider = google-beta
788
682
name = "%s"
789
683
routing_mode = "GLOBAL"
790
684
bgp_best_path_selection_mode = "STANDARD"
@@ -793,6 +687,7 @@ resource "google_compute_network" "acc_network_bgp_inter_region_cost" {
793
687
`, networkName, bgpInterRegionCost)
794
688
}
795
689
690
+ {{ if ne $.TargetVersionName `ga` -}}
796
691
func testAccComputeNetwork_network_profile(networkName, networkProfile string) string {
797
692
return fmt.Sprintf(`
798
693
resource "google_compute_network" "acc_network_network_profile" {
0 commit comments