Skip to content
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

Code Quality Issue #3

Open
bartmika opened this issue May 17, 2022 · 0 comments
Open

Code Quality Issue #3

bartmika opened this issue May 17, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@bartmika
Copy link
Owner

The following was taken from jerf via this reddit post:

GetFutureDateByFiveMinuteIntervalPattern and all its friends can be implemented as a GetFutureDate(interval time.Duration) time.Time and a GetFutureDateFrom(interval time.Duration, baseTime time.Time) time.Time. Look at the time.Truncate option. The first function can work by Truncating time.Now() to the given interval, then advancing one interval. The second can work with a bit more math around computing how far off the default truncated time the base time is. e.g., I should be able to call GetFutureDateFrom(50 * time.Minute, noonPlusOneMinute) and get a time with a 1 in the ones digit of the time (05:01, 07:31, etc).
Your tests are going to end up being not generally extensive enough. Speaking from experience, you're going to want to write tests that step through every possible time based on whatever interval you're testing (minutes, days, etc.), and also, one time exactly on the interval in question (e.g., exactly noon) and a time not exactly on the given interval (e.g., noon + 50 milliseconds, noon + 1 second), to test the behavior on the boundaries. I have no specific knowledge of what bug

@bartmika bartmika added the enhancement New feature or request label May 17, 2022
@bartmika bartmika self-assigned this May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant