[Bug 14693] New: t/db_dependent/Contract.t fails do to fixed date
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 Bug ID: 14693 Summary: t/db_dependent/Contract.t fails do to fixed date Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Test Suite Assignee: chris@bigballofwax.co.nz Reporter: tomascohen@gmail.com QA Contact: gmcharlt@gmail.com To reproduce: - Run (on master) $ prove t/db_dependent/Contract.t => FAIL: tests fail due to a fixed date (2015-07-31) being set as a future date which hasn't arrived yet. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 --- Comment #1 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 41682 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=41682&action=edit Bug 14693: Contract.t should generate dates based on current date The current test for still-active contracts fails because it was written with fixed dates, which already passed :-D This patch calculates the current date, and uses it to generate a future one, so the tests serve their purpose no matter what the current date is. To test: - Run: $ prove t/db_dependent/Contract.t => FAIL: activeonly compares contractenddate with now(), and fails because a fixed 2015-07-31 is writteng on the test data - Apply the patch - Run: $ prove t/db_dependent/Contract.t => SUCCESS: the sample data has been calculated using the current date and the tests pass. - Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|chris@bigballofwax.co.nz |tomascohen@gmail.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 --- Comment #2 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Comment on attachment 41682 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=41682 Bug 14693: Contract.t should generate dates based on current date Review of attachment 41682: --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=14693&attachment=41682) ----------------------------------------------------------------- ::: t/db_dependent/Contract.t @@ +72,5 @@
is( $contract->{contractdescription}, $my_contract1->{contractdescription}, 'AddContract stores the contract description correctly.' ); is( $contract->{booksellerid}, $my_contract1->{booksellerid}, 'AddContract stores the bookseller id correctly.' );
+my $now = dt_from_string; +my $three_more_days = $now + DateTime::Duration->new( days => 3 );
1/ DateTime::Duration should be imported 2/ Are you sure this works ? There are the 2 add_duration or subtract_duration methods, which is certainly better. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Jonathan Druart from comment #2)
Comment on attachment 41682 [details] [review] 1/ DateTime::Duration should be imported
I agree. Will fix it now.
2/ Are you sure this works ? There are the 2 add_duration or subtract_duration methods, which is certainly better.
It is just syntax sugar. Using the plus symbol is correctly documented on DateTime: $dt2 = $dt + $duration_object; $dt3 = $dt - $duration_object; I think it provides better readability. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #41682|0 |1 is obsolete| | --- Comment #4 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 41715 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=41715&action=edit Bug 14693: Contract.t should generate dates based on current date The current test for still-active contracts fails because it was written with fixed dates, which already passed :-D This patch calculates the current date, and uses it to generate a future one, so the tests serve their purpose no matter what the current date is. To test: - Run: $ prove t/db_dependent/Contract.t => FAIL: activeonly compares contractenddate with now(), and fails because a fixed 2015-07-31 is writteng on the test data - Apply the patch - Run: $ prove t/db_dependent/Contract.t => SUCCESS: the sample data has been calculated using the current date and the tests pass. - Sign off :-D Edit: added missing use DateTime::Duration, -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #41715|0 |1 is obsolete| | --- Comment #5 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 41785 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=41785&action=edit [SIGNED-OFF] Bug 14693: Contract.t should generate dates based on current date The current test for still-active contracts fails because it was written with fixed dates, which already passed :-D This patch calculates the current date, and uses it to generate a future one, so the tests serve their purpose no matter what the current date is. To test: - Run: $ prove t/db_dependent/Contract.t => FAIL: activeonly compares contractenddate with now(), and fails because a fixed 2015-07-31 is writteng on the test data - Apply the patch - Run: $ prove t/db_dependent/Contract.t => SUCCESS: the sample data has been calculated using the current date and the tests pass. - Sign off :-D Edit: added missing use DateTime::Duration, Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #41785|0 |1 is obsolete| | --- Comment #6 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 41786 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=41786&action=edit Bug 14693: Contract.t should generate dates based on current date The current test for still-active contracts fails because it was written with fixed dates, which already passed :-D This patch calculates the current date, and uses it to generate a future one, so the tests serve their purpose no matter what the current date is. To test: - Run: $ prove t/db_dependent/Contract.t => FAIL: activeonly compares contractenddate with now(), and fails because a fixed 2015-07-31 is writteng on the test data - Apply the patch - Run: $ prove t/db_dependent/Contract.t => SUCCESS: the sample data has been calculated using the current date and the tests pass. - Sign off :-D Edit: added missing use DateTime::Duration, Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14693 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master CC| |tomascohen@gmail.com --- Comment #7 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Fix pushed to master. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org