-
Notifications
You must be signed in to change notification settings - Fork 58
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
Use the current time for NewFakeClock's initial value #55
Conversation
Well, this change will. :) Frankly, I agree with your reasoning, but I'm also worried about the potential mass new issue opening that it may cause. One thing I would certainly do is expand in the function documentation a bit, telling people that they shouldn't rely on the time being deterministic when using |
No changes made yet, pending discussion.
I would be too, until I realized the cat is already out of the bag on that one with #52. I made this CL because I changed the default in that update, thinking .oO(Surely people wouldn't rely on the default time from Well, Hyrum's law had something to say about that. There were people in our code base depending on it. However, I went through the process of upgrading our code base to use All that is to say, which direction would you like to go with this?
I'm open to whatever you decide, just let me know. |
As you said, the cat is already out of the bag, so let's at least try to help people by adding a more explicit warning to Other than that (and a rebase), LGTM. |
Done. Let me know if that works. Happy to modify it as needed. |
After we get this merged, would it be possible to upgrade the version from 0.3.0 to 0.4.0? |
This prevents callers from building tests that rely on implementation details. Typically by expecting a string containing a static, default value of NewFakeClock(). This philosophy of preventing users from relying on implementation internals is similar to Go's random map iteration behavior. For users who depend on the initial clock time, NewFakeClockAt provides the behavior they need, and makes their expectations clear in tests.
Sure, no problem. I can see that you changed the fake clock initial value to the current time. Any particular reason why? I can't say why, but it sounds somewhat better than an arbitrary random value. |
I was motivated by what I thought was being requested in #61, although I now understand that issue to be asking for something else. I pondered it a bit this morning, and using Sorry for the late change with no comment beforehand. I was responding to #61. Maybe I should have commented first before pushing. My apologies for that. |
No worries! I believe this is a better solution, we just needed some time to find 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.
Thanks!
See - jonboulle/clockwork#55 - https://github.com/jonboulle/clockwork/blob/v0.3.0/clockwork.go#L42 Signed-off-by: Benjamin Wang <wachao@vmware.com>
clockwork has a new behaviour, cf: jonboulle/clockwork#55 so fixing those as well. bump to github/v52, i have a commit in there that fix a workaround i had to add for tkn pac info. wait.PollImmediate is deprecated, adding a nolint for now until wel this is removed :upside_down: Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
make minimal requirement to go 1.19 clockwork has a new behaviour, cf: jonboulle/clockwork#55 so fixing those as well. bump to github/v52, i have a commit in there that fix a workaround i had to add for tkn pac info which can be removed. wait.PollImmediate is deprecated, adding a nolint for now until wel this is removed :upside_down: Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
* update all docker image to latest latest go-toolset and 311 python Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com> * Update all dependencies make minimal requirement to go 1.19 clockwork has a new behaviour, cf: jonboulle/clockwork#55 so fixing those as well. bump to github/v52, i have a commit in there that fix a workaround i had to add for tkn pac info which can be removed. wait.PollImmediate is deprecated, adding a nolint for now until wel this is removed :upside_down: Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com> --------- Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
This prevents callers from building tests that rely on implementation details. Typically by expecting a time or string value computed from NewFakeClock().Now().
This philosophy of preventing users from relying on implementation internals is similar to Go's random map iteration behavior. For users who depend on the initial clock time, NewFakeClockAt() provides the behavior they need, and makes their expectations clear in tests.
This also ensures that future changes that might need to modify the default time for whatever reason won't cause mass breakage, as this author learned about the hard way.