@@ -9,15 +9,32 @@ import (
9
9
"github.com/hashicorp/terraform/terraform"
10
10
)
11
11
12
- func TestAccContainerClusterDatasource_basic (t * testing.T ) {
12
+ func TestAccContainerClusterDatasource_zonal (t * testing.T ) {
13
13
t .Parallel ()
14
14
15
15
resource .Test (t , resource.TestCase {
16
16
PreCheck : func () { testAccPreCheck (t ) },
17
17
Providers : testAccProviders ,
18
18
Steps : []resource.TestStep {
19
19
{
20
- Config : testAccContainerClusterDatasourceConfig ,
20
+ Config : testAccContainerClusterDatasource_zonal (),
21
+ Check : resource .ComposeTestCheckFunc (
22
+ testAccDataSourceGoogleContainerClusterCheck ("data.google_container_cluster.kubes" , "google_container_cluster.kubes" ),
23
+ ),
24
+ },
25
+ },
26
+ })
27
+ }
28
+
29
+ func TestAccContainerClusterDatasource_regional (t * testing.T ) {
30
+ t .Parallel ()
31
+
32
+ resource .Test (t , resource.TestCase {
33
+ PreCheck : func () { testAccPreCheck (t ) },
34
+ Providers : testAccProviders ,
35
+ Steps : []resource.TestStep {
36
+ {
37
+ Config : testAccContainerClusterDatasource_regional (),
21
38
Check : resource .ComposeTestCheckFunc (
22
39
testAccDataSourceGoogleContainerClusterCheck ("data.google_container_cluster.kubes" , "google_container_cluster.kubes" ),
23
40
),
@@ -88,20 +105,37 @@ func testAccDataSourceGoogleContainerClusterCheck(dataSourceName string, resourc
88
105
}
89
106
}
90
107
91
- var testAccContainerClusterDatasourceConfig = fmt .Sprintf (`
92
- resource "google_container_cluster" "kubes" {
93
- name = "cluster-test-%s"
94
- zone = "us-central1-a"
95
- initial_node_count = 1
108
+ func testAccContainerClusterDatasource_zonal () string {
109
+ return fmt .Sprintf (`
110
+ resource "google_container_cluster" "kubes" {
111
+ name = "cluster-test-%s"
112
+ zone = "us-central1-a"
113
+ initial_node_count = 1
96
114
97
- master_auth {
98
- username = "mr.yoda"
99
- password = "adoy.rm.123456789"
100
- }
115
+ master_auth {
116
+ username = "mr.yoda"
117
+ password = "adoy.rm.123456789"
101
118
}
119
+ }
102
120
103
- data "google_container_cluster" "kubes" {
104
- name = "${google_container_cluster.kubes.name}"
105
- zone = "${google_container_cluster.kubes.zone}"
106
- }
121
+ data "google_container_cluster" "kubes" {
122
+ name = "${google_container_cluster.kubes.name}"
123
+ zone = "${google_container_cluster.kubes.zone}"
124
+ }
107
125
` , acctest .RandString (10 ))
126
+ }
127
+
128
+ func testAccContainerClusterDatasource_regional () string {
129
+ return fmt .Sprintf (`
130
+ resource "google_container_cluster" "kubes" {
131
+ name = "cluster-test-%s"
132
+ region = "us-central1"
133
+ initial_node_count = 1
134
+ }
135
+
136
+ data "google_container_cluster" "kubes" {
137
+ name = "${google_container_cluster.kubes.name}"
138
+ region = "${google_container_cluster.kubes.region}"
139
+ }
140
+ ` , acctest .RandString (10 ))
141
+ }
0 commit comments