-
Notifications
You must be signed in to change notification settings - Fork 130
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
Tests that rely on Order.EMPTY
are time-sensitive
#6636
Comments
Hi @wzieba, I noticed this issue and find the idea of making Order.EMPTY time agnostic very interesting. Introducing a default date value like Instant.EPOCH and an injectable java.time.Clock for fixed values during tests sounds like a great approach to improve consistency and test reliability. Would it be alright if I take this up? I'd be happy to work on implementing this and addressing the naming concern regarding Order.EMPTY.isEmpty(). |
hi @Akshaykomar890 👋 thanks for being interested in improving this. As I'm not working on this project actively anymore, let me cc @malinajirka to provide their insight here. |
Hello again @Akshaykomar890 👋, thanks again for your interest in contributing! Feel free to work on this issue. I don't have much insights into the complexity of this issue, but I like the idea and the solution proposed by Wojtek sounds like a good one. Let me know in case you encounter any issues and I'll be happy to chat about them with you (and hopefully help you resolve them :P ). |
fix : woocommerce#6636 I implemented the Order class is refactored to remove time sensitivity in tests by using a fixed timestamp for the Order.EMPTY instance. Instead of generating dynamic timestamps, dateCreated and dateModified are assigned constant values using Date.from(Instant.EPOCH), which corresponds to the Unix epoch (January 1, 1970). This ensures that comparisons in tests remain consistent and predictable.
Hello @malinajirka, Thanks for your previous feedback and support. Thanks again |
All unit tests that use
Order.EMPTY
are now based on time, as since #6534 the time of creation is generated on eachget
.This means that when executing tests, we can't compare
Order.EMPTY
as it'll be different each time it's requested.IMO we should make
Order.EMPTY
time agnostic (assign a default value for date, e.g.Instant.EPOCH
) and introduce injectablejava.time.Clock
which will be a fixed one in tests.Also maybe it's a naming issue. Because
Order.EMPTY.isEmpty()
now returnsfalse
.The text was updated successfully, but these errors were encountered: