Summary: | t/db_dependent/Contract.t fails do to fixed date | ||
---|---|---|---|
Product: | Koha | Reporter: | Tomás Cohen Arazi (tcohen) <tomascohen> |
Component: | Test Suite | Assignee: | Tomás Cohen Arazi (tcohen) <tomascohen> |
Status: | CLOSED FIXED | QA Contact: | Galen Charlton <gmcharlt> |
Severity: | normal | ||
Priority: | P5 - low | CC: | tomascohen |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: | |||
Attachments: |
Bug 14693: Contract.t should generate dates based on current date
Bug 14693: Contract.t should generate dates based on current date [SIGNED-OFF] Bug 14693: Contract.t should generate dates based on current date Bug 14693: Contract.t should generate dates based on current date |
Description
Tomás Cohen Arazi (tcohen)
2015-08-19 13:26:42 UTC
Created attachment 41682 [details] [review] 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 Comment on attachment 41682 [details] [review] Bug 14693: Contract.t should generate dates based on current date Review of attachment 41682 [details] [review]: ----------------------------------------------------------------- ::: 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. (In reply to Jonathan Druart from comment #2) > Comment on attachment 41682 [details] [review] [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. Created attachment 41715 [details] [review] 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, Created attachment 41785 [details] [review] [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> Created attachment 41786 [details] [review] 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> Fix pushed to master. |