-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add more target tests, add invalid keyID error code #14
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 552944478Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
} | ||
} | ||
|
||
func TestODoHResolutionWithRealResolver(t *testing.T) { |
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.
This type of dependency shouldn't be in a unit test. Why did we go with 1.1.1.1 here?
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.
Likelihood of 1.1.1.1 being unavailable seems extremely low, and I wanted to exercise the resolve()
: https://github.com/cloudflare/odoh-server-go/blob/master/resolver.go#L47 codepath. I figured that the benefits of having atleast one test for that codepath far outweighed the risk of creating a 1.1.1.1 dependency.
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 get that, but I think we can exercise that path by mocking things (or wrapping resolve()
appropriately). Adding a network dependency doesn't seem to be the right answer.
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.
re: mocking it, personally I think exercising the networking codepath in resolve()
is pretty valuable
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.
But I can remove it if you think it's fine without.
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.
Testing the implementation of resolve()
isn't something this project should do. We should only be testing that the code that uses resolve
is correct, which is why I suggested mocking it.
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.
The key ID mismatch change looks good! I'm requesting changes because I don't think it's appropriate for unit tests to hit the network. (If we have a 1.1.1.1 dependency, let's mock it.)
No description provided.