-
Notifications
You must be signed in to change notification settings - Fork 91
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
Make FQDN lookup function more testable #158
Conversation
providers/shared/fqdn_test.go
Outdated
}{ | ||
"long_real_hostname": { | ||
osHostname: "elastic.co", | ||
expectedFQDN: "elastic.co", |
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.
Will temporary DNS errors cause this test to fail even if the logic is correct?
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.
Yeah, it will. Just tested it with my Internet connection turned off.
I'm hoping such network/DNS unavailability errors are extremely rare, though. Perhaps we could add a comment here and remove this test case if it starts proving to be flaky?
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.
I think a comment is a good idea, it won't necessarily be obvious that this requires an internet connection without context.
I'm fine waiting and seeing if this turns out to be flaky. Anyone testing this code will need to hit the real code path anyway so mocking it out doesn't necessarily help.
The tests added in this PR are failing in CI with a slightly different error (as returned by |
/test |
This PR refactors the
shared.FQDN()
function, extracting the lookup algorithm into a helper function, to make the code a bit more testable. Having done that, the PR also adds a unit test for the helper function.