Skip to content

Commit

Permalink
[chore] Fix filelog receiver test with new component.ValidateConfig
Browse files Browse the repository at this point in the history
… behavior (#37448)

#### Description

`component.ValidateConfig` now validates interfaces. The
`(*helper.TimeParser).Validate` method is now called while validating
`FileLogConfig` and as a result, the struct is modified during
validation. The simplest fix seemed to be to apply these same changes to
the expected config struct by calling `Validate` on it, even though the
assertion logic in the test now feels a little circular.

I can try to refactor the struct a bit to make it more directly testable
if desired.

This is needed for
#37447.

---------

Co-authored-by: Evan Bradley <[email protected]>
  • Loading branch information
evan-bradley and evan-bradley authored Jan 24, 2025
1 parent a441a27 commit 65ec900
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions receiver/filelogreceiver/filelog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ func testdataConfigYaml() *FileLogConfig {
timeCfg := helper.NewTimeParser()
timeCfg.Layout = "%Y-%m-%d"
timeCfg.ParseFrom = &timeField
// The Validate method modifies private fields on the helper.TimeParser
// object that need to be set for later comparison.
// If validation fails, the test will fail, so discard the error.
_ = timeCfg.Validate()
cfg.TimeParser = &timeCfg
return cfg
}(),
Expand Down

0 comments on commit 65ec900

Please sign in to comment.