This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
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.
For #9599: Ability to edit top site URLs #9600
For #9599: Ability to edit top site URLs #9600
Changes from 2 commits
9aa6504
c350bd9
f84dc4e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
There's nothing wrong in particular about this, but from looking around our codebase, I would be more comfortable being consistent and calling System.currentTimeMillis() where it is.
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 use it to inject a constant time from the tests (in
addAllDefaultSites
andaddPinnedSite
) so that I can useverify
without much effort. What would be a good alternative?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 we can just check for anyLong() as an alternative.
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 tried that but I think it doesn't work because the long is wrapped in an object. I think this works:
verify(obj).method(eq("foo"), anyLong())
But this doesn't:
verify(obj).method(SomeClass(eq("foo"), anyLong()))
And our case matches the latter. But I don't really have a lot of experience in this area so please correct me if I'm missing something. The real problem I think we're having is that there is no consistent way to mock time used throughout the project. Code that does straight calls to
System.currentTimeMillis()
is just not very unit-testable. Perhaps we should make an issue about this?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 is nice!
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.
Thank you!