Bug 8649 - C4::Search needs a unit test
Summary: C4::Search needs a unit test
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: 3.10
Hardware: All All
: P5 - low enhancement (vote)
Target Milestone: ---
Assignee: Jared Camins-Esakov
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 8648
Blocks: 8211
  Show dependency treegraph
 
Reported: 2012-08-15 20:50 UTC by Jared Camins-Esakov
Modified: 2013-12-05 20:01 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 8649: Add unit test for C4::Search (175.14 KB, patch)
2012-08-16 16:50 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
[SIGNED-OFF] 0002-Bug-8649-Add-unit-test-for-C4-Search.patch (175.23 KB, patch)
2012-08-16 20:54 UTC, wajasu
Details | Diff | Splinter Review
[SIGNED-OFF] 0003-bug-8649-make-sure-C4-Context-is-fully-mocked-up-bef.patch (2.93 KB, patch)
2012-08-16 20:56 UTC, wajasu
Details | Diff | Splinter Review
[SIGNED-OFF] 0004-bug-8649-make-sure-we-can-exit-if-a-test-fails.patch (1.43 KB, patch)
2012-08-16 20:57 UTC, wajasu
Details | Diff | Splinter Review
[SIGNED-OFF] 0005-bug-8649-create-a-temp-directory-for-Zebra-for-C4-Se.patch (8.61 KB, patch)
2012-08-16 20:58 UTC, wajasu
Details | Diff | Splinter Review
[SIGNED-OFF] 0006-bug-8649-quiet-a-variable-use-warning.patch (797 bytes, patch)
2012-08-16 21:01 UTC, wajasu
Details | Diff | Splinter Review
Bug 8649: Add unit test for C4::Search (175.29 KB, patch)
2012-08-31 18:19 UTC, Kyle M Hall
Details | Diff | Splinter Review
bug 8649: make sure C4::Context is fully mocked-up before tests (2.97 KB, patch)
2012-08-31 18:19 UTC, Kyle M Hall
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 8649: Add unit test for C4::Search (175.29 KB, patch)
2012-08-31 18:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
[SIGNED-OFF] bug 8649: make sure C4::Context is fully mocked-up before tests (2.97 KB, patch)
2012-08-31 18:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
[SIGNED-OFF] bug 8649: make sure we can exit if a test fails (1.48 KB, patch)
2012-08-31 18:21 UTC, Kyle M Hall
Details | Diff | Splinter Review
[SIGNED-OFF] bug 8649: make sure we can exit if a test fails (1.48 KB, patch)
2012-08-31 18:24 UTC, Kyle M Hall
Details | Diff | Splinter Review
[SIGNED-OFF] bug 8649: create a temp directory for Zebra for C4::Search tests (8.58 KB, patch)
2012-08-31 18:25 UTC, Kyle M Hall
Details | Diff | Splinter Review
[SIGNED-OFF] bug 8649: quiet a variable use warning (853 bytes, patch)
2012-08-31 18:25 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jared Camins-Esakov 2012-08-15 20:50:33 UTC
Due to the size of the patch, it seems better to put this test on a separate bug than 5327 where other unit tests for C4 are going.
Comment 1 Jared Camins-Esakov 2012-08-15 21:11:19 UTC
Please sign off the patch in the search_t branch of my GitHub repo: https://github.com/jcamins/koha/tree/search_t

I tried to attach the patch but it is too large.
Comment 2 Jared Camins-Esakov 2012-08-16 16:50:22 UTC Comment hidden (obsolete)
Comment 3 wajasu 2012-08-16 20:54:10 UTC Comment hidden (obsolete)
Comment 4 wajasu 2012-08-16 20:56:20 UTC Comment hidden (obsolete)
Comment 5 wajasu 2012-08-16 20:57:34 UTC Comment hidden (obsolete)
Comment 6 wajasu 2012-08-16 20:58:46 UTC Comment hidden (obsolete)
Comment 7 wajasu 2012-08-16 21:01:30 UTC Comment hidden (obsolete)
Comment 8 Kyle M Hall 2012-08-31 18:19:29 UTC Comment hidden (obsolete)
Comment 9 Kyle M Hall 2012-08-31 18:19:53 UTC Comment hidden (obsolete)
Comment 10 Kyle M Hall 2012-08-31 18:20:22 UTC
Created attachment 11927 [details] [review]
[SIGNED-OFF] Bug 8649: Add unit test for C4::Search

This patch adds a unit test for C4::Search in t/db_dependent. In order
to test the functioning of the Zebra search, this patch actually includes
an entire Zebra sandbox, and pre-indexed files, which are stored in
t/db_dependent/data (the configuration files are generated on the fly).

This test depends on Test::Warn, Test::MockModule, and DBD::Mock.

To test:
1) Run the test. There should be no failures, and no warnings.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 11 Kyle M Hall 2012-08-31 18:20:43 UTC
Created attachment 11928 [details] [review]
[SIGNED-OFF] bug 8649: make sure C4::Context is fully mocked-up before tests

This fixes failures of the test cases to run for me
on Perl 5.10.1 using prove -v t/db_dependent/Search.t

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 12 Kyle M Hall 2012-08-31 18:21:19 UTC Comment hidden (obsolete)
Comment 13 Kyle M Hall 2012-08-31 18:24:41 UTC
Created attachment 11930 [details] [review]
[SIGNED-OFF] bug 8649: make sure we can exit if a test fails

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 14 Kyle M Hall 2012-08-31 18:25:10 UTC
Created attachment 11931 [details] [review]
[SIGNED-OFF] bug 8649: create a temp directory for Zebra for C4::Search tests

The Zebra test uses Unix-domain sockets, which won't work if
Koha is being installed or tested from an NFS- or SSHFS-mounted
clone.  Therefore, create (and clenaup) a temporary directory on
(hopefully) a normal filesytem to run the test.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 15 Kyle M Hall 2012-08-31 18:25:31 UTC
Created attachment 11932 [details] [review]
[SIGNED-OFF] bug 8649: quiet a variable use warning

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 16 Mason James 2012-09-11 03:39:34 UTC
(In reply to comment #15)
> Created attachment 11932 [details] [review]
> [SIGNED-OFF] bug 8649: quiet a variable use warning
> 
> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
> Signed-off-by: wajasu <matted-34813@mypacks.net>
> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

passing QA on this.. very nice work!

$ koha-qa.pl -c  5 

testing 5 commit(s) (applied to commit c8ef17e)
 * b085f62 bug 8649: quiet a variable use warning
      t/db_dependent/Search.t

 * b733df4 bug 8649: create a temp directory for Zebra for C4::Search tests
      t/db_dependent/Search.t
      t/db_dependent/data/var/lib/zebradb/authorities/key/README
      t/db_dependent/data/var/lib/zebradb/authorities/register/README
      t/db_dependent/data/var/lib/zebradb/authorities/shadow/README
      t/db_dependent/data/var/lib/zebradb/authorities/tmp/README
      t/db_dependent/data/var/lib/zebradb/biblios/key/README
      t/db_dependent/data/var/lib/zebradb/biblios/register/README
      t/db_dependent/data/var/lib/zebradb/biblios/shadow/README
      t/db_dependent/data/var/lib/zebradb/biblios/tmp/README
      t/db_dependent/data/var/lock/zebradb/authorities/README
      t/db_dependent/data/var/lock/zebradb/biblios/README
      t/db_dependent/data/var/log/README
      t/db_dependent/data/var/run/zebradb/README
      t/db_dependent/zebra_config.pl

 * bbfd59a bug 8649: make sure we can exit if a test fails
      t/db_dependent/Search.t

 * 2c46ed7 bug 8649: make sure C4::Context is fully mocked-up before tests
      t/db_dependent/Search.t

 * 3568a1f Bug 8649: Add unit test for C4::Search
      C4/Installer/PerlDependencies.pm
      t/db_dependent/Search.t
      t/db_dependent/data/var/lib/zebradb/authorities/key/README
      t/db_dependent/data/var/lib/zebradb/authorities/register/README
      t/db_dependent/data/var/lib/zebradb/authorities/shadow/README
      t/db_dependent/data/var/lib/zebradb/authorities/tmp/README
      t/db_dependent/data/var/lib/zebradb/biblios/key/README
      t/db_dependent/data/var/lib/zebradb/biblios/register/README
      t/db_dependent/data/var/lib/zebradb/biblios/shadow/README
      t/db_dependent/data/var/lib/zebradb/biblios/tmp/README
      t/db_dependent/data/var/lock/zebradb/authorities/README
      t/db_dependent/data/var/lock/zebradb/biblios/README
      t/db_dependent/data/var/log/README
      t/db_dependent/data/var/run/zebradb/README
      t/db_dependent/data/zebraexport/authority/exported_records
      t/db_dependent/data/zebraexport/biblio/exported_records
      t/db_dependent/zebra_config.pl

* t/db_dependent/Search.t                                                  OK
* t/db_dependent/zebra_config.pl                                           OK
* C4/Installer/PerlDependencies.pm                                         OK
Comment 17 Mason James 2012-09-11 03:42:33 UTC
> 
> passing QA on this.. very nice work!

test completes with PASS, as expected... ;)

$ prove  t/db_dependent/Search.t             
t/db_dependent/Search.t .. ok     
All tests successful.
Files=1, Tests=57,  4 wallclock secs ( 0.02 usr  0.01 sys +  2.20 cusr  0.63 csys =  2.86 CPU)
Result: PASS
Comment 18 Paul Poulain 2012-09-13 10:00:57 UTC
Patch pushed to master

great job !

question = are those tests really db_dependent ?
Comment 19 Jared Camins-Esakov 2012-09-13 11:13:50 UTC
(In reply to comment #18)
> Patch pushed to master
> 
> great job !
> 
> question = are those tests really db_dependent ?

Unfortunately, yes. You don't need any data in your database, but you do have to have a database. One of the BEGIN blocks in one of the modules that C4::Search includes.
Comment 20 Jared Camins-Esakov 2012-12-03 13:22:30 UTC
C4::Search now has a unit test.