Skip to content

Commit e3a4a40

Browse files
test(block_fastly_service_logging_logentries_test): fix tests for logentries to account for API behavior (#1143)
* test(block_fastly_service_logging_logentries_test): fix tests for log entries to account for API behavior
1 parent a1791ce commit e3a4a40

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### BUG FIXES:
1010

1111
- fix(header): preserve optional bool field `ignore_if_set` during updates and add acceptance test coverage ([#1142](https://github.com/fastly/terraform-provider-fastly/pull/1142))
12+
- fix(block_fastly_service_logging_logentries_test): fix tests for logentries to account for API behavior ([#1143](https://github.com/fastly/terraform-provider-fastly/pull/1143))
1213
- fix(image_optimizer_default_settings): preserve optional bool fields (`allow_video`, `webp`, `upscale`) during updates and add acceptance test coverage ([#1145](https://github.com/fastly/terraform-provider-fastly/pull/1145))
1314
- fix(logging_kafka): preserve optional bool fields (`use_tls`, `parse_log_keyvals`) during updates and add acceptance test coverage ([#1147](https://github.com/fastly/terraform-provider-fastly/pull/1147))
1415
- fix(product_enablement): ensure `ddos_protection` mode updates are applied ([#1149](https://github.com/fastly/terraform-provider-fastly/pull/1149))

fastly/block_fastly_service_logging_logentries_test.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestAccFastlyServiceVCL_logentries_basic(t *testing.T) {
3838
Port: gofastly.ToPointer(10000),
3939
UseTLS: gofastly.ToPointer(false),
4040
Token: gofastly.ToPointer("newtoken"),
41-
Format: gofastly.ToPointer(LoggingFormatUpdate),
41+
Format: gofastly.ToPointer(`%h %u %t %r %>s`),
4242
FormatVersion: gofastly.ToPointer(2),
4343
ResponseCondition: gofastly.ToPointer("response_condition_test"),
4444
ProcessingRegion: gofastly.ToPointer("none"),
@@ -153,8 +153,26 @@ func testAccCheckFastlyServiceVCLLogentriesAttributes(service *gofastly.ServiceD
153153
ls.Placement = s.Placement
154154
}
155155

156-
if !reflect.DeepEqual(s, ls) {
157-
return fmt.Errorf("bad match Logentries logging match,\nexpected:\n(%#v),\ngot:\n(%#v)", s, ls)
156+
if *s.Format != *ls.Format {
157+
return fmt.Errorf("bad Logentries Format match for service %s,\nexpected:\n(%s),\ngot:\n(%s)", *s.Name, *s.Format, *ls.Format)
158+
}
159+
if *s.FormatVersion != *ls.FormatVersion {
160+
return fmt.Errorf("bad Logentries FormatVersion match for service %s,\nexpected:\n(%d),\ngot:\n(%d)", *s.Name, *s.FormatVersion, *ls.FormatVersion)
161+
}
162+
if *s.Port != *ls.Port {
163+
return fmt.Errorf("bad Logentries Port match for service %s,\nexpected:\n(%d),\ngot:\n(%d)", *s.Name, *s.Port, *ls.Port)
164+
}
165+
if *s.UseTLS != *ls.UseTLS {
166+
return fmt.Errorf("bad Logentries UseTLS match for service %s,\nexpected:\n(%t),\ngot:\n(%t)", *s.Name, *s.UseTLS, *ls.UseTLS)
167+
}
168+
if *s.Token != *ls.Token {
169+
return fmt.Errorf("bad Logentries Token match for service %s,\nexpected:\n(%s),\ngot:\n(%s)", *s.Name, *s.Token, *ls.Token)
170+
}
171+
if *s.ResponseCondition != *ls.ResponseCondition {
172+
return fmt.Errorf("bad Logentries ResponseCondition match for service %s,\nexpected:\n(%s),\ngot:\n(%s)", *s.Name, *s.ResponseCondition, *ls.ResponseCondition)
173+
}
174+
if *s.ProcessingRegion != *ls.ProcessingRegion {
175+
return fmt.Errorf("bad Logentries ProcessingRegion match for service %s,\nexpected:\n(%s),\ngot:\n(%s)", *s.Name, *s.ProcessingRegion, *ls.ProcessingRegion)
158176
}
159177
found++
160178
}
@@ -183,6 +201,7 @@ func TestAccFastlyServiceVCL_logentries_formatVersion(t *testing.T) {
183201
Format: gofastly.ToPointer(`%h %l %u %t "%r" %>s %b`),
184202
FormatVersion: gofastly.ToPointer(2),
185203
ResponseCondition: gofastly.ToPointer("response_condition_test"),
204+
ProcessingRegion: gofastly.ToPointer("us"),
186205
}
187206

188207
resource.ParallelTest(t, resource.TestCase{
@@ -227,7 +246,7 @@ resource "fastly_service_compute" "foo" {
227246
logging_logentries {
228247
name = "somelogentriesname"
229248
token = "token"
230-
processing_region = "us"
249+
processing_region = "us"
231250
}
232251
233252
package {
@@ -261,7 +280,7 @@ resource "fastly_service_vcl" "foo" {
261280
name = "somelogentriesname"
262281
token = "token"
263282
response_condition = "response_condition_test"
264-
processing_region = "us"
283+
processing_region = "us"
265284
}
266285
force_destroy = true
267286
}`, name, domain)
@@ -289,6 +308,7 @@ resource "fastly_service_vcl" "foo" {
289308
name = "somelogentriesname"
290309
token = "token"
291310
response_condition = "response_condition_test"
311+
processing_region = "us"
292312
}
293313
logging_logentries {
294314
name = "somelogentriesanothername"
@@ -297,6 +317,7 @@ resource "fastly_service_vcl" "foo" {
297317
token = "newtoken"
298318
format = "%%h %%u %%t %%r %%>s"
299319
response_condition = "response_condition_test"
320+
processing_region = "none"
300321
}
301322
force_destroy = true
302323
}`, name, domain)
@@ -325,6 +346,7 @@ resource "fastly_service_vcl" "foo" {
325346
token = "token"
326347
response_condition = "response_condition_test"
327348
format_version = 2
349+
processing_region = "us"
328350
}
329351
force_destroy = true
330352
}`, name, domain)

0 commit comments

Comments
 (0)