You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having said that, the ability the override such stuff exists in many Golang libraries via conventional OverrideFooFunc facilities, which seems like a good addition to this library but I do not see it bringing much of a value testing wise.
My purpose is to can test a function that use now.BeginingOf..., not to use now inside a test.
For example we cannot add a test in this package for the function now.BeginningOfWeek(). I mean it's an usual issue to test a function that use the current datetime...
Describe the feature
It's difficult to test function in main like
now.BeginingOf...
because it usetime.Now()
I suggest that the function
time.Now
could be set global likevar WeekStartDay = time.Sunday
We could have
var TimeNowFunction = time.Now
now.BeginingOfDay()
will becomereturn With(TimeNowFunction()).BeginningOfDay()
Then when we start our test we just need to set
now.TimeNowFunction = func() time.Time { return time.Date(2021, 1, 1, 0, 0, 0, 0, time.Local) }
Thanks to listen
The text was updated successfully, but these errors were encountered: