@@ -176,6 +176,61 @@ func TestAccFastlyServiceVCLRequestSetting_basic(t *testing.T) {
176176 })
177177}
178178
179+ func TestAccFastlyServiceVCLRequestSetting_PreserveBooleansDuringUpdate (t * testing.T ) {
180+ var service gofastly.ServiceDetail
181+ serviceName := acctest .RandomWithPrefix ("tf-rs" )
182+ domainName := fmt .Sprintf ("test.%s.com" , acctest .RandString (10 ))
183+
184+ rsName := "rs-update"
185+
186+ // Optional boolean values we want to preserve
187+ forceMiss := true
188+ forceSSL := false
189+ bypassBusyWait := true
190+ timerSupport := true
191+
192+ initialDefaultHost := "initial.example.com"
193+ updatedDefaultHost := "updated.example.com"
194+
195+ resource .ParallelTest (t , resource.TestCase {
196+ PreCheck : func () { testAccPreCheck (t ) },
197+ ProviderFactories : testAccProviders ,
198+ CheckDestroy : testAccCheckServiceVCLDestroy ,
199+ Steps : []resource.TestStep {
200+ {
201+ Config : testAccServiceVCLRequestSettingWithBooleansAndHost (serviceName , domainName , rsName , initialDefaultHost , forceMiss , forceSSL , bypassBusyWait , timerSupport ),
202+ Check : resource .ComposeTestCheckFunc (
203+ testAccCheckServiceExists ("fastly_service_vcl.foo" , & service ),
204+ resource .TestCheckResourceAttr ("fastly_service_vcl.foo" , "request_setting.#" , "1" ),
205+ resource .TestCheckTypeSetElemNestedAttrs ("fastly_service_vcl.foo" , "request_setting.*" , map [string ]string {
206+ "name" : rsName ,
207+ "default_host" : initialDefaultHost ,
208+ "force_miss" : fmt .Sprintf ("%t" , forceMiss ),
209+ "force_ssl" : fmt .Sprintf ("%t" , forceSSL ),
210+ "bypass_busy_wait" : fmt .Sprintf ("%t" , bypassBusyWait ),
211+ "timer_support" : fmt .Sprintf ("%t" , timerSupport ),
212+ }),
213+ ),
214+ },
215+ {
216+ Config : testAccServiceVCLRequestSettingWithBooleansAndHost (serviceName , domainName , rsName , updatedDefaultHost , forceMiss , forceSSL , bypassBusyWait , timerSupport ),
217+ Check : resource .ComposeTestCheckFunc (
218+ testAccCheckServiceExists ("fastly_service_vcl.foo" , & service ),
219+ resource .TestCheckResourceAttr ("fastly_service_vcl.foo" , "request_setting.#" , "1" ),
220+ resource .TestCheckTypeSetElemNestedAttrs ("fastly_service_vcl.foo" , "request_setting.*" , map [string ]string {
221+ "name" : rsName ,
222+ "default_host" : updatedDefaultHost ,
223+ "force_miss" : fmt .Sprintf ("%t" , forceMiss ),
224+ "force_ssl" : fmt .Sprintf ("%t" , forceSSL ),
225+ "bypass_busy_wait" : fmt .Sprintf ("%t" , bypassBusyWait ),
226+ "timer_support" : fmt .Sprintf ("%t" , timerSupport ),
227+ }),
228+ ),
229+ },
230+ },
231+ })
232+ }
233+
179234func testAccCheckFastlyServiceVCLRequestSettingsAttributes (service * gofastly.ServiceDetail , rqs []* gofastly.RequestSetting ) resource.TestCheckFunc {
180235 return func (_ * terraform.State ) error {
181236 conn := testAccProvider .Meta ().(* APIClient ).conn
@@ -261,3 +316,32 @@ resource "fastly_service_vcl" "foo" {
261316 force_destroy = true
262317}` , name , domain , action , maxStaleAge )
263318}
319+
320+ func testAccServiceVCLRequestSettingWithBooleansAndHost (serviceName , domainName , rsName , defaultHost string , forceMiss , forceSSL , bypassBusyWait , timerSupport bool ) string {
321+ return fmt .Sprintf (`
322+ resource "fastly_service_vcl" "foo" {
323+ name = "%s"
324+
325+ domain {
326+ name = "%s"
327+ comment = "test domain"
328+ }
329+
330+ backend {
331+ address = "http-me.fastly.dev"
332+ name = "main-backend"
333+ port = 80
334+ }
335+
336+ request_setting {
337+ name = "%s"
338+ default_host = "%s"
339+ force_miss = %t
340+ force_ssl = %t
341+ bypass_busy_wait = %t
342+ timer_support = %t
343+ }
344+
345+ force_destroy = true
346+ }` , serviceName , domainName , rsName , defaultHost , forceMiss , forceSSL , bypassBusyWait , timerSupport )
347+ }
0 commit comments