Modify time first, round after (and strip additional precision). #568
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE. Let's discuss this change first.
I've noticed that TestDo_rateLimit_noNetworkCall test fails on Go master with the following error:
(Source: https://travis-ci.org/google/go-github/jobs/205180544.)
This is due to changes in Go 1.9 to perform monotonic elapsed time measurements. See golang/go#12914 and https://golang.org/design/12914-monotonic for full details.
Make the test pass by modifying time first, round after, and strip the monotonic clock reading by using
AddDate(0, 0, 0)
. Doing that eliminates the unwanted additional monotonic precision from wanted time, making the expected time equality true.This is also related to an open issue golang/go#18991. Depending on the outcome there, this PR could be simplified not to need
AddDate(0, 0, 0)
.I just wanted to get this PR created for visibility. We can discuss the potential fix, and wait on Go 1.9 to get closer to release before actually merging this, because there may be additional changes that would render this change overly complex or unnecessary.