-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
new BeAfter matcher for time.Time values #41
Conversation
I just added a HaveKeyValue matcher to match a map's key and value. Usage like: |
A few thoughts: I really like I think the motivation for First: unfortunately, I don't think we can change the behavior of format w.r.t to time.Time. For one reason why check out the second comment on issue #37 Instead, I think this matcher should just do its own formatting. Either by adding a format.Time() method or just doing the formatting inline. Second: Ω(t1).Should(BeTemporally(">", t2)
Ω(t1).Should(BeTemporally(">=", t2)
Ω(t1).Should(BeTemporally("=", t2)
Ω(t1).Should(BeTemporally("<=", t2)
Ω(t1).Should(BeTemporally("<", t2)
Ω(t1).Should(BeTemporally("~", t2, time.Millisecond) Thoughts? |
And, it goes without saying: thanks for working on these! |
I'll make the change to HaveKeyWithValue |
How's that? :-) |
|
This PR's getting close. I have one more minor nit before merging in if you don't mind fixing it! Instead of func BeTemporally(comparator string, compareTo ...interface{}) OmegaMatcher {
return &matchers.BeTemporallyMatcher{
Comparator: comparator,
CompareTo: compareTo,
}
} which forces a type check at runtime we could enforce the type check at compile time with: func BeTemporally(comparator string, compareTo time.Time, threshold ...time.Duration) OmegaMatcher {
return &matchers.BeTemporallyMatcher{
Comparator: comparator,
CompareTo: compareTo,
Threshold: threshold,
}
} Would you mind making that change? Once it's done I think this'll be ready to merge! |
I had wondered about that myself and wasn't sure whether you specifically wanted interface{} on all these params. I'll make the change. After that, additional changes are all yours ;-) |
Thanks! Sorry for the nitpicking - excited to merge this in! |
Nah, no worries, I rather contribute to a project that has a nitpicky committer than someone who merges any garbage in! |
I changed the args of BeTemporally to time.Time/time.Duration. I left the actual as interface{} and am not sure about the pros/cons of making that a time.Time as well. Happy to make that change too ;-) |
looks good to me! |
new BeAfter matcher for time.Time values
also, don't worry about the docs. I'll update the github pages later today/tomorrow. |
I created a new matcher for time.Time values. See the tests for simple usage. Please advise whether this is acceptable or whether you'd like modifications or don't like it at all. :-)
(If this looks good, I'll also create a pull request for the docs)