Bug 13276 - t/XSLT.t shouldn't depend on the DB
Summary: t/XSLT.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 (vote)
Assignee: Chris Cormack
QA Contact: Galen Charlton
URL:
Keywords:
Depends on:
Blocks: 13275
  Show dependency treegraph
 
Reported: 2014-11-18 03:50 UTC by Tomás Cohen Arazi
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:


Attachments
Bug 13276: t/XSLT.t shouldn't depend on the DB (2.48 KB, patch)
2014-11-18 03:53 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 13276: t/XSLT.t shouldn't depend on the DB (2.54 KB, patch)
2014-11-18 07:21 UTC, Chris Cormack
Details | Diff | Splinter Review
[PASSED QA] Bug 13276: t/XSLT.t shouldn't depend on the DB (2.65 KB, patch)
2014-11-18 07:29 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 13276: use t::lib::Mocks::mock_dbh (1.07 KB, patch)
2014-11-18 09:58 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 2014-11-18 03:50:01 UTC
t/XSLT.t should mock the DB
Comment 1 Tomás Cohen Arazi 2014-11-18 03:53:18 UTC Comment hidden (obsolete)
Comment 2 Magnus Enger 2014-11-18 07:13:26 UTC
*Before* applying the patch:

$ sudo koha-shell -c "prove  t/XSLT.t" kohadev
t/XSLT.t .. ok   
All tests successful.
Files=1, Tests=8,  2 wallclock secs ( 0.02 usr  0.01 sys +  0.48 cusr  0.45 csys =  0.96 CPU)
Result: PASS

As far as I can tell, the patch adds mocking of C4::Context but never uses that for anything? Perhaps I am missing something but I'm setting this to Failed QA.
Comment 3 Chris Cormack 2014-11-18 07:20:26 UTC
Before patch I get

#   Failed test 'use C4::XSLT;'
#   at t/XSLT.t line 14.
#     Tried to use 'C4::XSLT'.
#     Error:  Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at C4/Context.pm line 785.

After the patch it works
Comment 4 Chris Cormack 2014-11-18 07:21:23 UTC Comment hidden (obsolete)
Comment 5 Katrin Fischer 2014-11-18 07:29:13 UTC
Created attachment 33640 [details] [review]
[PASSED QA] Bug 13276: t/XSLT.t shouldn't depend on the DB

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

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

Regards

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Tests pass without db connection for me now.
Comment 6 Jonathan Druart 2014-11-18 09:58:21 UTC
Created attachment 33646 [details] [review]
Bug 13276: use t::lib::Mocks::mock_dbh

To use this patch, patch from bug 13274 should be applied too.
Comment 7 Jonathan Druart 2014-11-18 09:59:35 UTC
The last patch reintroduces the use_ok into the BEGIN block and use the mock subroutine introduced by the patch on bug 13274 comment 4.
Feel free not to use/push it.
Comment 8 Tomás Cohen Arazi 2014-11-19 14:42:03 UTC
Patches pushed to master.

Thanks Jonathan!