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.
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.
Created attachment 11642 [details] [review] 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.
Created attachment 11648 [details] [review] [SIGNED-OFF] 0002-Bug-8649-Add-unit-test-for-C4-Search.patch
Created attachment 11649 [details] [review] [SIGNED-OFF] 0003-bug-8649-make-sure-C4-Context-is-fully-mocked-up-bef.patch
Created attachment 11650 [details] [review] [SIGNED-OFF] 0004-bug-8649-make-sure-we-can-exit-if-a-test-fails.patch
Created attachment 11651 [details] [review] [SIGNED-OFF] 0005-bug-8649-create-a-temp-directory-for-Zebra-for-C4-Se.patch
Created attachment 11652 [details] [review] [SIGNED-OFF] 0006-bug-8649-quiet-a-variable-use-warning.patch For the record, when signing off, jcamins, gmcharlt, and wajasu collabrated for the patches, and it resulted in 5 commits, which preserve the history of work done. Pardon my explicit TODO list: 1) git clone git://git.koha-community.org/koha.git kohaclone ; cd kohaclone 2) git remote add gkohatest https://github.com/gmcharlt/koha-test.git 3) git fetch gkohatest 4) git branch bug8649_signed_off gkohatest/bug8649_signed_off 5) git checkout bug8649_signed_off 6) prove t/db_dependent/Search.t t/db_dependent/Search.t .. ok All tests successful. Files=1, Tests=57, 7 wallclock secs ( 0.02 usr 0.01 sys + 2.37 cusr 0.41 csys = 2.81 CPU) Result: PASS 7) there was much rejoicing 8) commited the last commits in my local test branch pertaining to this bug git commit --amend -s -c fd27241a0c57e696a28966abe4024ce29616660b git commit --amend -s -c 6f379b594363b6703f7b261c0f6c03bd164a70c0 git commit --amend -s -c e1e21badfc45f4b442870d4ebea719836d012b18 git commit --amend -s -c 3719c6c3f61243a058bd34101e7d1cb787ba9713 git commit --amend -s -c 9efbc14cf9eaab554881e189916b5ac2eca8c712 9) git format-patch -s origin/master and sent patches to mailing list 10) attached them to bugzilla Note: 0002-0006 ( a total of 5 patches ) is what is required Congrats to jcamins on the excellent test for zebra Search and to gmcharlt on supportive patches which runs without a hitch in my koha test VM, over a sshfs mounted kohaclone. :) wajasu
Created attachment 11925 [details] [review] 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>
Created attachment 11926 [details] [review] 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>
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>
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>
Created attachment 11929 [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>
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>
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>
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>
(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
> > 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
Patch pushed to master great job ! question = are those tests really db_dependent ?
(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.
C4::Search now has a unit test.