Bug 13274 - t/00-load.t shouldn't depend on the DB
Summary: t/00-load.t shouldn't depend on the DB
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Chris Cormack
QA Contact: Galen Charlton
URL:
Keywords:
Depends on:
Blocks: 13275
  Show dependency treegraph
 
Reported: 2014-11-18 03:23 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2015-06-04 23:33 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 13274: t/00-load.t shouldn't depend on the DB (3.25 KB, patch)
2014-11-18 03:29 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
[SIGNED OFF] Bug 13274: t/00-load.t shouldn't depend on the DB (3.51 KB, patch)
2014-11-18 04:37 UTC, Mark Tompsett
Details | Diff | Splinter Review
[PASSED QA] Bug 13274: t/00-load.t shouldn't depend on the DB (3.62 KB, patch)
2014-11-18 06:53 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 13274: Mock new_dbh in t::lib::Mocks (1.69 KB, patch)
2014-11-18 09:46 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED OFF] Bug 13274: Mock new_dbh in t::lib::Mocks (1.88 KB, patch)
2014-11-18 13:21 UTC, Mark Tompsett
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2014-11-18 03:23:49 UTC
t/00-load.t should mock the DB connection.
Comment 1 Tomás Cohen Arazi (tcohen) 2014-11-18 03:29:09 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2014-11-18 04:37:05 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2014-11-18 06:53:19 UTC
Created attachment 33638 [details] [review]
[PASSED QA] Bug 13274: t/00-load.t shouldn't depend on the DB

To reproduce:
- Stop your MySQL server:
  $ sudo service mysql stop
- Run
  $ prove t/00-load.t
=> FAIL: some tests fail because of mysql stopped

To test (MySQL still stopped)
- Apply the patch
- Run
  $ prove t/00-load.t
=> SUCCESS: tests pass because the ycan be loaded regardless of
            the absence of the DB server
- Sign off :-D

NOTE: Even seems to grab more than expected, which is good.
      349 tests in master vs 364 in this branch = 16,
      but removed block is only 13 (lines 20-32).
      Also ran koha-qa test tool. :)

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Works as described, tests passing now without database available.
Comment 4 Jonathan Druart 2014-11-18 09:46:29 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2014-11-18 09:47:40 UTC
Please have a look at the last patch.
Maybe it would be better to create a routine in t::lib::Mocks to avoid to c/p theses lines in all related bugs.
Comment 6 Mark Tompsett 2014-11-18 13:21:33 UTC
Created attachment 33649 [details] [review]
[SIGNED OFF] Bug 13274: Mock new_dbh in t::lib::Mocks

This patch suggests to create a routine to mock C4::Context::_new_dbh.

NOTE: Works the same with and without this secondary patch.
      koha-qa tests fine. Less cutting and pasting in the future.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 7 Tomás Cohen Arazi (tcohen) 2014-11-19 14:42:13 UTC
Patches pushed to master.