News for hackers. Stuff that matters.
Re:Mocking time and testing event loops in Go by TheDong on Tuesday May 26, 2020 @04:55PM (#23316279)
We're misunderstanding each other then.

I assumed this package about mocking time was _not_ about mocking timestamps but program behavior. For example, if I have a loop that says "every 20 seconds, do X", and I want to test that, I now have to mock time.

That's not about timestamps, that's about comparing monotonic clocks for "20s have elapsed".

The go time package doesn't just give you a timestamp to do something with, it also lets you compare times. That was my point.

It sounds like your original comment was arguing that mocking time isn't useful, so I assumed you meant all uses of time.

Re:Mocking time and testing event loops in Go by loopz on Thursday May 28, 2020 @12:20PM (#23339079)
Fair enough. If you want to mock time differentials like that, I see that one could use something to mock that. However, what you probably ideally would want to mock are the order of events, and not certain language-specific stdlib-calls. Though would depend how explicit you want to define your domain.