Description
Mark Tompsett
2016-07-07 01:37:05 UTC
Created attachment 53154 [details]
auth_header.sql
My auth_header which triggered this problem.
perhaps a:
use koha_library;
source auth_header.sql;
might be useful for testing. Don't push anywhere!
Created attachment 53155 [details] [review] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t When the auth_header table has records which exclude 1xx and 2xx tags, the $bibfield doesn't match anything. This in turn sets it to undef, which triggers an error on the next line killing the test. LIMIT was removed as it is not necessary and is a MySQL-ism. Though this may slow down testing with huge auth_header files, it should not be significant. TEST PLAN --------- 1) back up DB 2) Make sure to add in some authority records. 3) DELETE FROM auth_header WHERE marcxml LIKE '%datafield tag="1%'; DELETE FROM auth_header WHERE marcxml LIKE '%datafield tag="2%'; -- Now the test should blow up nicely. -- If you find you have no records, add more such that you repeat steps 2 and 3 and still have records in auth_header. Sorry, getting the trigger data is the hard part. 4) prove t/db_dependent/Linker_FirstMatch.t -- should barf before running all the tests 5) apply patch 6) prove t/db_dependent/Linker_FirstMatch.t -- should have pretty skip message(s) 7) run koha qa test tools 8) restore your backup Created attachment 53411 [details] [review] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t When the auth_header table has records which exclude 1xx and 2xx tags, the $bibfield doesn't match anything. This in turn sets it to undef, which triggers an error on the next line killing the test. LIMIT was removed as it is not necessary and is a MySQL-ism. Though this may slow down testing with huge auth_header files, it should not be significant. TEST PLAN --------- 1) back up DB 2) Make sure to add in some authority records. 3) DELETE FROM auth_header WHERE marcxml LIKE '%datafield tag="1%'; DELETE FROM auth_header WHERE marcxml LIKE '%datafield tag="2%'; -- Now the test should blow up nicely. -- If you find you have no records, add more such that you repeat steps 2 and 3 and still have records in auth_header. Sorry, getting the trigger data is the hard part. 4) prove t/db_dependent/Linker_FirstMatch.t -- should barf before running all the tests 5) apply patch 6) prove t/db_dependent/Linker_FirstMatch.t -- should have pretty skip message(s) 7) run koha qa test tools 8) restore your backup Signed-off-by: Marc Véron <veron@veron.ch> Instead of trying to fix specific case, I'd suggest to insert the data you want to make the tests pass: - Start transaction - Create the authority you want - Retrieve the authority and use it for the tests. (In reply to Jonathan Druart from comment #4) > Instead of trying to fix specific case, I'd suggest to insert the data you > want to make the tests pass: > - Start transaction > - Create the authority you want > - Retrieve the authority and use it for the tests. Okay, I'll refactor to use t::lib::Database (your code from bug 14334) and t::lib::TestBuilder. Created attachment 53451 [details] [review] Bug 16868: Jonathan Druart testing dbh code I grabbed the code from bug 14334, and will use it here. prove t/db_dependent/Linker_FirstMatch.t will demonstrate it works. Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Created attachment 53452 [details] [review] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t When the auth_header table has records which exclude 1xx and 2xx tags, the $bibfield doesn't match anything. This in turn sets it to undef, which triggers an error on the next line killing the test. This was completely refactored to provide the data necessary for the tests to pass, and to be more comprehensive (both MARC and UNIMARC are tested). The tests are then run. TEST PLAN --------- 1) back up DB 2) DELETE FROM auth_header; 3) SOURCE auth_header.sql; -- the provided file 4) prove t/db_dependent/Linker_FirstMatch.t -- should barf before running all the tests 5) apply all patches 6) prove t/db_dependent/Linker_FirstMatch.t -- should work happy 7) run koha qa test tools 8) restore your backup Created attachment 53453 [details] [review] Bug 16868: Jonathan Druart testing dbh code I grabbed the code from bug 14334, and will use it here. prove t/db_dependent/Linker_FirstMatch.t will demonstrate it works. Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Created attachment 53454 [details] [review] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t When the auth_header table has records which exclude 1xx and 2xx tags, the $bibfield doesn't match anything. This in turn sets it to undef, which triggers an error on the next line killing the test. This was completely refactored to provide the data necessary for the tests to pass, and to be more comprehensive (both MARC and UNIMARC are tested). The tests are then run. TEST PLAN --------- 1) back up DB 2) DELETE FROM auth_header; 3) SOURCE auth_header.sql; -- the provided file 4) prove t/db_dependent/Linker_FirstMatch.t -- should barf before running all the tests 5) apply all patches 6) prove t/db_dependent/Linker_FirstMatch.t -- should work happy 7) run koha qa test tools 8) restore your backup Comment on attachment 53454 [details] [review] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t Review of attachment 53454 [details] [review]: ----------------------------------------------------------------- ::: t/db_dependent/Linker_FirstMatch.t @@ -36,3 @@ > my $tag = $bibfield->tag(); > - $tag =~ s/^./6/; > - $bibfield->update(tag => $tag); For the record, this code never worked. It doesn't change the tag, it adds a subfield called tag. Created attachment 53455 [details] [review] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t When the auth_header table has records which exclude 1xx and 2xx tags, the $bibfield doesn't match anything. This in turn sets it to undef, which triggers an error on the next line killing the test. This was completely refactored to provide the data necessary for the tests to pass, and to be more comprehensive (both MARC and UNIMARC are tested). The tests are then run. TEST PLAN --------- 1) back up DB 2) DELETE FROM auth_header; 3) SOURCE auth_header.sql; -- the provided file 4) prove t/db_dependent/Linker_FirstMatch.t -- should barf before running all the tests 5) apply all patches 6) prove t/db_dependent/Linker_FirstMatch.t -- should work happy 7) run koha qa test tools 8) restore your backup Mark, could you please do something like this instead? (grabbed from some other test and adjusted to your use). sub get_authtority_record { my $main_heading_field = ( C4::Context->preference('MARCFlavour') eq 'UNIMARC' ) ? '200' : '100'; my $auth = MARC::Record->new(); $auth->append_fields( MARC::Field->new($main_heading_field, ' ', ' ', a => 'Geisel, Theodor Seuss,', d => '1904-1991' )); return $auth; } It seems to me that the interpolated XML stuff obfuscates the code, and does unneeded XML processing. Also, the global transaction for tests was discouraged so no need to introduce Database.pm for this simple test as we just do the transaction as it is needed in the tests (think of subtests that do its own rollbacks, etc). So go for the usual: use Koha::Database; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; < tests here > $schema->storage->txn_rollback; BTW, it seems to me that this tests don't bother to launch zebra so they... don't... actually... test anything? Good examples on how to do this can be found (for C&P) on search_utf8.t <- This is not your fault and not really part of your bug report, but worth mentioning. The relevant test, is the last one, and it depends on zebra having the record indexed!! Notice C4::Headings::authorities() is calling _search() which actually triggers a Zebra search. (In reply to Tomás Cohen Arazi from comment #12) > Mark, could you please do something like ... [SNIP] Okay... I'll adjust based on your feedback. Created attachment 53549 [details] [review] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t When the auth_header table has records which exclude 1xx and 2xx tags, the $bibfield doesn't match anything. This in turn sets it to undef, which triggers an error on the next line killing the test. This was completely refactored to provide the data necessary for the tests to pass, and to be more comprehensive (both MARC and UNIMARC are tested). The tests are then run. C4::Headings::authorities is mocked, so that this test is not dependent on a search engine. TEST PLAN --------- 1) back up DB 2) DELETE FROM auth_header; 3) SOURCE auth_header.sql; -- the provided file 4) prove t/db_dependent/Linker_FirstMatch.t -- should barf before running all the tests 5) apply all patches 6) prove t/db_dependent/Linker_FirstMatch.t -- should work happy 7) run koha qa test tools 8) restore your backup Created attachment 53729 [details] [review] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t When the auth_header table has records which exclude 1xx and 2xx tags, the $bibfield doesn't match anything. This in turn sets it to undef, which triggers an error on the next line killing the test. This was completely refactored to provide the data necessary for the tests to pass, and to be more comprehensive (both MARC and UNIMARC are tested). The tests are then run. C4::Headings::authorities is mocked, so that this test is not dependent on a search engine. TEST PLAN --------- 1) back up DB 2) DELETE FROM auth_header; 3) SOURCE auth_header.sql; -- the provided file 4) prove t/db_dependent/Linker_FirstMatch.t -- should barf before running all the tests 5) apply all patches 6) prove t/db_dependent/Linker_FirstMatch.t -- should work happy 7) run koha qa test tools 8) restore your backup Followed test plan, behaves as expected. Signed-off-by: Marc <veron@veron.ch> Created attachment 53880 [details] [review] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t When the auth_header table has records which exclude 1xx and 2xx tags, the $bibfield doesn't match anything. This in turn sets it to undef, which triggers an error on the next line killing the test. This was completely refactored to provide the data necessary for the tests to pass, and to be more comprehensive (both MARC and UNIMARC are tested). The tests are then run. C4::Headings::authorities is mocked, so that this test is not dependent on a search engine. TEST PLAN --------- 1) back up DB 2) DELETE FROM auth_header; 3) SOURCE auth_header.sql; -- the provided file 4) prove t/db_dependent/Linker_FirstMatch.t -- should barf before running all the tests 5) apply all patches 6) prove t/db_dependent/Linker_FirstMatch.t -- should work happy 7) run koha qa test tools 8) restore your backup Followed test plan, behaves as expected. Signed-off-by: Marc <veron@veron.ch> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Pushed to master. Should be in the November 2016 release. Thanks! Pushed in 16.05. Will be in 16.05.03. |