@@ -198,6 +198,64 @@ func TestAccCloudflareLoadBalancerPool_VirtualNetworkID(t *testing.T) {
198
198
})
199
199
}
200
200
201
+ func TestAccCloudflareLoadBalancerPool_PatchBehavior (t * testing.T ) {
202
+ t .Parallel ()
203
+ testStartTime := time .Now ().UTC ()
204
+ var loadBalancerPool cfold.LoadBalancerPool
205
+ rnd := utils .GenerateRandomResourceName ()
206
+ name := "cloudflare_load_balancer_pool." + rnd
207
+ accountID := os .Getenv ("CLOUDFLARE_ACCOUNT_ID" )
208
+
209
+ resource .Test (t , resource.TestCase {
210
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
211
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
212
+ CheckDestroy : testAccCheckCloudflareLoadBalancerPoolDestroy ,
213
+ Steps : []resource.TestStep {
214
+ {
215
+ Config : testAccCheckCloudflareLoadBalancerPoolConfigBasic (rnd , accountID ),
216
+ Check : resource .ComposeTestCheckFunc (
217
+ testAccCheckCloudflareLoadBalancerPoolExists (name , & loadBalancerPool ),
218
+ resource .TestCheckResourceAttr (name , "name" , fmt .Sprintf ("my-tf-pool-basic-%s" , rnd )),
219
+ resource .TestCheckResourceAttr (name , "enabled" , "true" ),
220
+ resource .TestCheckResourceAttr (name , "latitude" , "12.3" ),
221
+ resource .TestCheckResourceAttr (name , "longitude" , "55" ),
222
+ resource .TestCheckResourceAttr (name , "origins.#" , "1" ),
223
+ resource .TestCheckResourceAttr (name , "origins.0.name" , "example-1" ),
224
+ resource .TestCheckResourceAttr (name , "origins.0.address" , "192.0.2.1" ),
225
+ testAccCheckCloudflareLoadBalancerPoolDates (name , & loadBalancerPool , testStartTime ),
226
+ ),
227
+ },
228
+ {
229
+ // Patch the load balancer pool with updated properties
230
+ Config : testAccCheckCloudflareLoadBalancerPoolConfigPatched (rnd , accountID ),
231
+ Check : resource .ComposeTestCheckFunc (
232
+ testAccCheckCloudflareLoadBalancerPoolExists (name , & loadBalancerPool ),
233
+ // Verify patched properties
234
+ resource .TestCheckResourceAttr (name , "name" , fmt .Sprintf ("my-tf-pool-patched-%s" , rnd )),
235
+ resource .TestCheckResourceAttr (name , "description" , "Patched load balancer pool" ),
236
+ resource .TestCheckResourceAttr (name , "enabled" , "false" ),
237
+ resource .TestCheckResourceAttr (name , "latitude" , "37.7749" ),
238
+ resource .TestCheckResourceAttr (name , "longitude" , "-122.4194" ),
239
+ resource .TestCheckResourceAttr (name , "minimum_origins" , "2" ),
240
+ resource .TestCheckResourceAttr (name , "check_regions.#" , "1" ),
241
+ resource .TestCheckResourceAttr (name , "check_regions.0" , "WEU" ),
242
+ resource .TestCheckResourceAttr (name , "origins.#" , "2" ),
243
+ resource .TestCheckResourceAttr (name , "origins.0.name" , "patched-origin-1" ),
244
+ resource .TestCheckResourceAttr (name , "origins.0.address" , "192.0.2.2" ),
245
+ resource .TestCheckResourceAttr (name , "origins.1.name" , "patched-origin-2" ),
246
+ resource .TestCheckResourceAttr (name , "origins.1.address" , "192.0.2.3" ),
247
+ resource .TestCheckResourceAttr (name , "load_shedding.%" , "4" ),
248
+ resource .TestCheckResourceAttr (name , "load_shedding.default_percent" , "25" ),
249
+ resource .TestCheckResourceAttr (name , "load_shedding.default_policy" , "random" ),
250
+ resource .TestCheckResourceAttr (name , "origin_steering.%" , "1" ),
251
+ resource .TestCheckResourceAttr (name , "origin_steering.policy" , "random" ),
252
+ testAccCheckCloudflareLoadBalancerPoolDates (name , & loadBalancerPool , testStartTime ),
253
+ ),
254
+ },
255
+ },
256
+ })
257
+ }
258
+
201
259
func TestAccCloudflareLoadBalancerPool_FullySpecified (t * testing.T ) {
202
260
t .Parallel ()
203
261
var loadBalancerPool cfold.LoadBalancerPool
@@ -421,6 +479,10 @@ func testAccCheckCloudflareLoadBalancerPoolConfigFullySpecified(id, headerValue,
421
479
// TODO add field to config after creating monitor resource
422
480
}
423
481
482
+ func testAccCheckCloudflareLoadBalancerPoolConfigPatched (id , accountID string ) string {
483
+ return acctest .LoadTestCase ("loadbalancerpoolconfigpatched.tf" , id , accountID )
484
+ }
485
+
424
486
func testAccCheckCloudflareTunnelVirtualNetworkExists (name string , virtualNetwork * cfold.TunnelVirtualNetwork ) resource.TestCheckFunc {
425
487
return func (s * terraform.State ) error {
426
488
rs , ok := s .RootModule ().Resources [name ]
0 commit comments