-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix panic caused by incorrect type assert. #377
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,13 @@ func TestAccFastlyServiceV1_gzips_basic(t *testing.T) { | |
ContentTypes: "text/javascript application/x-javascript application/javascript text/css text/html", | ||
} | ||
|
||
log4 := gofastly.Gzip{ | ||
ServiceVersion: 1, | ||
Name: "all", | ||
Extensions: "css", | ||
ContentTypes: "text/javascript application/x-javascript", | ||
} | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
|
@@ -145,7 +152,7 @@ func TestAccFastlyServiceV1_gzips_basic(t *testing.T) { | |
}, | ||
|
||
{ | ||
Config: testAccServiceV1GzipsConfig_update(name, domainName1), | ||
Config: testAccServiceV1GzipsConfig_delete_create(name, domainName1), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckServiceV1Exists("fastly_service_v1.foo", &service), | ||
testAccCheckFastlyServiceV1GzipsAttributes(&service, []*gofastly.Gzip{&log3}), | ||
|
@@ -155,6 +162,18 @@ func TestAccFastlyServiceV1_gzips_basic(t *testing.T) { | |
"fastly_service_v1.foo", "gzip.#", "1"), | ||
), | ||
}, | ||
|
||
{ | ||
Config: testAccServiceV1GzipsConfig_update(name, domainName1), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckServiceV1Exists("fastly_service_v1.foo", &service), | ||
testAccCheckFastlyServiceV1GzipsAttributes(&service, []*gofastly.Gzip{&log4}), | ||
resource.TestCheckResourceAttr( | ||
"fastly_service_v1.foo", "name", name), | ||
resource.TestCheckResourceAttr( | ||
"fastly_service_v1.foo", "gzip.#", "1"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
@@ -240,7 +259,7 @@ resource "fastly_service_v1" "foo" { | |
}`, name, domain) | ||
} | ||
|
||
func testAccServiceV1GzipsConfig_update(name, domain string) string { | ||
func testAccServiceV1GzipsConfig_delete_create(name, domain string) string { | ||
return fmt.Sprintf(` | ||
resource "fastly_service_v1" "foo" { | ||
name = "%s" | ||
|
@@ -272,3 +291,32 @@ resource "fastly_service_v1" "foo" { | |
force_destroy = true | ||
}`, name, domain) | ||
} | ||
|
||
func testAccServiceV1GzipsConfig_update(name, domain string) string { | ||
return fmt.Sprintf(` | ||
resource "fastly_service_v1" "foo" { | ||
name = "%s" | ||
|
||
domain { | ||
name = "%s" | ||
comment = "tf-testing-domain" | ||
} | ||
|
||
backend { | ||
address = "aws.amazon.com" | ||
name = "amazon docs" | ||
} | ||
|
||
gzip { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to clarify why this new test validates the actual 'update' mechanics... The original test thought it was validating a 'modification' to the gzip resource, but because they changed the name field (along with other fields) it meant that the gzip resource was actually being 'deleted' and then 'recreated' so the 'modification' logic (which is where the panic happens) was never actually run. To ensure the modification/update logic is executed I created a new test that updated the gzip resource but left the name the same and just modified some of the other fields. |
||
name = "all" | ||
extensions = ["css"] | ||
|
||
content_types = [ | ||
"application/x-javascript", | ||
"text/javascript", | ||
] | ||
} | ||
|
||
force_destroy = true | ||
}`, name, domain) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting here for reviewers, this API accepts the types as a space-seperated list, so this is correct 👍
https://developer.fastly.com/reference/api/vcl-services/gzip/