Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tanyav2
Copy link
Contributor

@tanyav2 tanyav2 commented Feb 9, 2021

No description provided.

@coveralls
Copy link

coveralls commented Feb 9, 2021

Pull Request Test Coverage Report for Build 552944478

Warning: 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

  • 8 of 13 (61.54%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+4.4%) to 51.844%

Changes Missing Coverage Covered Lines Changed/Added Lines %
target.go 8 13 61.54%
Totals Coverage Status
Change from base Build 549355364: 4.4%
Covered Lines: 239
Relevant Lines: 461

💛 - Coveralls

@tanyav2 tanyav2 mentioned this pull request Feb 9, 2021
}
}

func TestODoHResolutionWithRealResolver(t *testing.T) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@chris-wood chris-wood left a 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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants