Skip to content

Commit ca21bd7

Browse files
test(header): update boolean preservation test to trigger Update() via priority
1 parent 673731c commit ca21bd7

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

fastly/block_fastly_service_header_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,35 +234,37 @@ func TestAccFastlyServiceVCL_headers_basic(t *testing.T) {
234234
})
235235
}
236236

237-
func TestAccFastlyServiceVCL_headers_PreserveIgnoreIfSetDuringNameChange(t *testing.T) {
237+
func TestAccFastlyServiceVCL_headers_PreserveIgnoreIfSetDuringPriorityUpdate(t *testing.T) {
238238
var service gofastly.ServiceDetail
239239
serviceName := acctest.RandomWithPrefix("tf-header")
240240
domainName := fmt.Sprintf("test.%s.com", acctest.RandString(10))
241-
242-
initialHeaderName := "header-initial"
243-
updatedHeaderName := "header-renamed"
241+
headerName := "header-priority-update"
244242
ignoreIfSet := true
245243

244+
initialPriority := 100
245+
updatedPriority := 150
246+
246247
resource.ParallelTest(t, resource.TestCase{
247248
PreCheck: func() { testAccPreCheck(t) },
248249
ProviderFactories: testAccProviders,
249250
CheckDestroy: testAccCheckServiceVCLDestroy,
250251
Steps: []resource.TestStep{
251252
{
252-
Config: testAccServiceVCLHeaderWithIgnoreIfSet(serviceName, domainName, initialHeaderName, ignoreIfSet),
253+
Config: testAccServiceVCLHeaderWithIgnoreIfSetAndPriority(serviceName, domainName, headerName, ignoreIfSet, initialPriority),
253254
Check: resource.ComposeTestCheckFunc(
254255
testAccCheckServiceExists("fastly_service_vcl.foo", &service),
255256
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "header.#", "1"),
256257
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "header.0.ignore_if_set", fmt.Sprintf("%t", ignoreIfSet)),
258+
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "header.0.priority", fmt.Sprintf("%d", initialPriority)),
257259
),
258260
},
259261
{
260-
// Change only the name
261-
Config: testAccServiceVCLHeaderWithIgnoreIfSet(serviceName, domainName, updatedHeaderName, ignoreIfSet),
262+
Config: testAccServiceVCLHeaderWithIgnoreIfSetAndPriority(serviceName, domainName, headerName, ignoreIfSet, updatedPriority),
262263
Check: resource.ComposeTestCheckFunc(
263264
testAccCheckServiceExists("fastly_service_vcl.foo", &service),
264265
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "header.#", "1"),
265266
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "header.0.ignore_if_set", fmt.Sprintf("%t", ignoreIfSet)),
267+
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "header.0.priority", fmt.Sprintf("%d", updatedPriority)),
266268
),
267269
},
268270
},
@@ -410,7 +412,7 @@ resource "fastly_service_vcl" "foo" {
410412
}`, name, domain)
411413
}
412414

413-
func testAccServiceVCLHeaderWithIgnoreIfSet(serviceName, domainName, headerName string, ignoreIfSet bool) string {
415+
func testAccServiceVCLHeaderWithIgnoreIfSetAndPriority(serviceName, domainName, headerName string, ignoreIfSet bool, priority int) string {
414416
return fmt.Sprintf(`
415417
resource "fastly_service_vcl" "foo" {
416418
name = "%s"
@@ -430,8 +432,10 @@ resource "fastly_service_vcl" "foo" {
430432
action = "delete"
431433
name = "%s"
432434
ignore_if_set = %t
435+
priority = %d
433436
}
434437
435438
force_destroy = true
436-
}`, serviceName, domainName, headerName, ignoreIfSet)
439+
}
440+
`, serviceName, domainName, headerName, ignoreIfSet, priority)
437441
}

0 commit comments

Comments
 (0)