Bug 15082 - t/db_dependent/Search.t shouldn't mock the DB connection
Summary: t/db_dependent/Search.t shouldn't mock the DB connection
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Galen Charlton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-29 14:20 UTC by Tomás Cohen Arazi
Modified: 2016-06-21 21:40 UTC (History)
2 users (show)

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


Attachments
Bug 15082: t/db_dependent/Search.t shouldn't mock the DB connection (2.81 KB, patch)
2015-10-29 14:26 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 15082: t/db_dependent/Search.t shouldn't mock the DB connection (2.94 KB, patch)
2015-10-29 15:34 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 15082: t/db_dependent/Search.t shouldn't mock the DB connection (3.00 KB, patch)
2015-10-29 16:05 UTC, Jonathan Druart
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 2015-10-29 14:20:34 UTC
DB-dependent tests don't need to mock the DB. Actually, this one is not using the mock at all, so we might be hiding side effects.

It seems that as the configuration file is created on each test run, we just need to grab the DB configuration from C4::Context and use it in rewrite-config.PL to go un-mocked.
Comment 1 Tomás Cohen Arazi 2015-10-29 14:26:43 UTC Comment hidden (obsolete)
Comment 2 Bernardo Gonzalez Kriegel 2015-10-29 15:34:46 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2015-10-29 16:05:25 UTC
Created attachment 44169 [details] [review]
Bug 15082: t/db_dependent/Search.t shouldn't mock the DB connection

This patch makes the t/db_dependent/Search.t tests use a real DB instead of
mocking the DB handler (which is not actually used and generates unnecesary
warnings when running the tests).

It does so by grabbing the DB configuration data using C4::Context->config()
and passing it (writing %ENV) to rewrite-config.PL, all is done in zebra_config.pl
which is only used on the Search.t file.

To test:
- Run
  $ prove t/db_dependent/Search.t
=> FAIL: Warnings are raised about DB being mocked and DBIC not recognising 'Mock'
         as a valid DB driver.
- Apply the patch
- Run
  $ prove r/db_dependent/Search.t
=> SUCCESS: Same tests results, no warning about DBIC driver.
- Sign off :-D

Disclamer: As of writing this patch, the Search.t tests pass. The patch is not dealing
with tests results, but how they use the DB.

Sponsored-by: Universidad Nacional de Cordoba

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Test pass before & after, a 'little' less noisy
No errors

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Tomás Cohen Arazi 2015-10-29 17:25:06 UTC
Patch pushed to master.