forked from hashicorp/terraform-provider-google-beta
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresource_compute_external_vpn_gateway_test.go
108 lines (97 loc) · 3.25 KB
/
resource_compute_external_vpn_gateway_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package compute_test
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
)
func TestAccComputeExternalVPNGateway_updateLabels(t *testing.T) {
t.Parallel()
rnd := acctest.RandString(t, 10)
resourceName := "google_compute_external_vpn_gateway.external_gateway"
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccComputeExternalVPNGateway_updateLabels(rnd, "test", "test"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "labels.%", "1"),
resource.TestCheckResourceAttr(resourceName, "labels.test", "test"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
{
Config: testAccComputeExternalVPNGateway_updateLabels(rnd, "test-updated", "test-updated"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "labels.%", "1"),
resource.TestCheckResourceAttr(resourceName, "labels.test-updated", "test-updated"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
},
})
}
func testAccComputeExternalVPNGateway_updateLabels(suffix, key, value string) string {
return fmt.Sprintf(`
resource "google_compute_external_vpn_gateway" "external_gateway" {
name = "tf-test-external-gateway-%s"
redundancy_type = "SINGLE_IP_INTERNALLY_REDUNDANT"
description = "An externally managed VPN gateway"
interface {
id = 0
ip_address = "8.8.8.8"
}
labels = {
%s = "%s"
}
}
`, suffix, key, value)
}
func TestAccComputeExternalVPNGateway_insertIpv6Address(t *testing.T) {
t.Parallel()
rnd := acctest.RandString(t, 10)
resourceName := "google_compute_external_vpn_gateway.external_gateway"
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: computeExternalVPNGatewayIpv6AddressConfig(rnd, "2001:db8:abcd:1234:5678:90ab:cdef:1234"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "interface.0.ipv6_address", "2001:db8:abcd:1234:5678:90ab:cdef:1234"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func computeExternalVPNGatewayIpv6AddressConfig(suffix, ipv6_address string) string {
return fmt.Sprintf(`
resource "google_compute_external_vpn_gateway" "external_gateway" {
name = "tf-test-external-gateway-%s"
redundancy_type = "SINGLE_IP_INTERNALLY_REDUNDANT"
description = "An externally managed VPN gateway"
interface {
id = 0
ipv6_address = "%s"
}
}
`, suffix, ipv6_address)
}