Bug 13933

Summary: t/DateUtils.t causes the build to break (from bug 13601)
Product: Koha Reporter: Robin Sheat <robin>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Galen Charlton <gmcharlt>
Severity: blocker    
Priority: P5 - low CC: jonathan.druart, katrin.fischer, nicolas.legrand, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13601
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 13933: Fix t/DateUtils.t without DB
Bug 13933: Fix t/DateUtils.t without DB
[PASSED QA] Bug 13933: Fix t/DateUtils.t without DB
Reproduce Bug 13933

Description Robin Sheat 2015-03-31 01:16:26 UTC
DBI connect('dbname=koha;host=localhost;port=3306','kohaadmin',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/DBIx/Connector.pm line 32
Can't call method "do" on unblessed reference at /tmp/buildd/koha-3.19~git+20150331135711.7fa67b2f/blib/PERL_MODULE_DIR/C4/Context.pm line 817.
# Looks like you planned 55 tests but ran 4.
# Looks like your test exited with 255 just after 4.
t/DateUtils.t ....................... 

This is caused by:

commit dd9f456ab7c2f0e66173a6feb7df2a38604c82cd
Author: Jonathan Druart <jonathan.druart@biblibre.com>
Date:   Tue Jan 20 15:28:19 2015 +0100

    Bug 13601: Add tests to highlight the problems with DateTime::Format::DateParse
Comment 1 Jonathan Druart 2015-03-31 08:00:20 UTC Comment hidden (obsolete)
Comment 2 Nicolas Legrand 2015-03-31 08:08:04 UTC Comment hidden (obsolete)
Comment 3 Kyle M Hall 2015-04-01 15:40:17 UTC
Created attachment 37422 [details] [review]
[PASSED QA] Bug 13933: Fix t/DateUtils.t without DB

If the mysql server is not running, the DateUtils.t tests failed.
This is caused by

commit dd9f456ab7c2f0e66173a6feb7df2a38604c82cd
    Bug 13601: Add tests to highlight the problems with
    DateTime::Format::DateParse

The pref dateformat and TimeFormat were retrieved before the mock.
Before bug 13601, the complete preference method was mocked, that's why
the error did not appear.

Test plan:
  sudo service mysql stop
  prove t/DateUtils.t
should be happy

Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Tomás Cohen Arazi 2015-04-01 16:13:46 UTC
Patch pushed to master.

Thanks Jonathan!
Comment 5 Robin Sheat 2015-04-01 22:04:21 UTC
Cheers, I had a quick look but I couldn't actually see _why_ it was happening.
Comment 6 Nicolas Legrand 2015-04-02 13:17:11 UTC Comment hidden (obsolete)
Comment 7 Nicolas Legrand 2015-04-02 13:20:40 UTC
argh sorry wrong bug, is there a way to remove my attachment and comments?
Comment 8 Nicolas Legrand 2015-04-02 13:25:12 UTC
Comment on attachment 37436 [details]
Reproduce Bug 13933

Make it obsolete, sorry for the noise :(
Comment 9 Jonathan Druart 2015-04-07 07:48:27 UTC
(In reply to Robin Sheat from comment #5)
> Cheers, I had a quick look but I couldn't actually see _why_ it was
> happening.

It's what I tried to explain in the commit description. Before 13601, the C4::Context->preference method was mocked: for all calls, "us" was returned.
The patches for 13601 replaced this global mock with a call to t::lib::Mocks::mock_preference, which mocks only the dateformat pref.
But somewhere (dt_from_string if I remember correctly) the value for TimeFormat is retrieved. Since it's not mocked, the value in the DB is picked.
You know the rest of the story :)