@@ -20,13 +20,14 @@ import (
20
20
func TestAccContainerCluster_basic (t * testing.T ) {
21
21
t .Parallel ()
22
22
23
+ clusterName := fmt .Sprintf ("cluster-test-%s" , acctest .RandString (10 ))
23
24
resource .Test (t , resource.TestCase {
24
25
PreCheck : func () { testAccPreCheck (t ) },
25
26
Providers : testAccProviders ,
26
27
CheckDestroy : testAccCheckContainerClusterDestroy ,
27
28
Steps : []resource.TestStep {
28
29
{
29
- Config : testAccContainerCluster_basic (fmt . Sprintf ( "cluster-test-%s" , acctest . RandString ( 10 )) ),
30
+ Config : testAccContainerCluster_basic (clusterName ),
30
31
Check : resource .ComposeTestCheckFunc (
31
32
testAccCheckContainerCluster (
32
33
"google_container_cluster.primary" ),
@@ -135,6 +136,20 @@ func TestAccContainerCluster_withNetworkPolicyEnabled(t *testing.T) {
135
136
"network_policy" ),
136
137
),
137
138
},
139
+ {
140
+ Config : testAccContainerCluster_withNetworkPolicyDisabled (clusterName ),
141
+ Check : resource .ComposeTestCheckFunc (
142
+ testAccCheckContainerCluster (
143
+ "google_container_cluster.with_network_policy_enabled" ),
144
+ resource .TestCheckResourceAttr ("google_container_cluster.with_network_policy_enabled" ,
145
+ "network_policy.0.enabled" , "false" ),
146
+ ),
147
+ },
148
+ {
149
+ Config : testAccContainerCluster_withNetworkPolicyDisabled (clusterName ),
150
+ PlanOnly : true ,
151
+ ExpectNonEmptyPlan : false ,
152
+ },
138
153
},
139
154
})
140
155
}
@@ -1085,6 +1100,17 @@ resource "google_container_cluster" "with_network_policy_enabled" {
1085
1100
}` , clusterName )
1086
1101
}
1087
1102
1103
+ func testAccContainerCluster_withNetworkPolicyDisabled (clusterName string ) string {
1104
+ return fmt .Sprintf (`
1105
+ resource "google_container_cluster" "with_network_policy_enabled" {
1106
+ name = "%s"
1107
+ zone = "us-central1-a"
1108
+ initial_node_count = 1
1109
+
1110
+ network_policy = {}
1111
+ }` , clusterName )
1112
+ }
1113
+
1088
1114
func testAccContainerCluster_withMasterAuthorizedNetworksConfig (clusterName string , cidrs []string ) string {
1089
1115
1090
1116
cidrBlocks := ""
0 commit comments