Bugzilla – Attachment 102149 Details for
Bug 22001
Add RaiseError and PrintError flags for all tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22001: Make the DBD error regex less strict
Bug-22001-Make-the-DBD-error-regex-less-strict.patch (text/plain), 7.18 KB, created by
Jonathan Druart
on 2020-03-31 15:59:04 UTC
(
hide
)
Description:
Bug 22001: Make the DBD error regex less strict
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-31 15:59:04 UTC
Size:
7.18 KB
patch
obsolete
>From 28039cac0b01e4bc839006a980a602c8f741027a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 31 Mar 2020 17:53:47 +0200 >Subject: [PATCH] Bug 22001: Make the DBD error regex less strict > >Now the message is looking like >DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry >--- > t/db_dependent/Illrequests.t | 2 +- > t/db_dependent/Reports/Guided.t | 8 ++++---- > t/db_dependent/api/v1/acquisitions_orders.t | 2 +- > t/db_dependent/api/v1/libraries.t | 2 +- > t/db_dependent/api/v1/patrons.t | 8 ++++---- > t/db_dependent/api/v1/return_claims.t | 2 +- > 6 files changed, 12 insertions(+), 12 deletions(-) > >diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Illrequests.t >index 15cb844276..bc8e170958 100644 >--- a/t/db_dependent/Illrequests.t >+++ b/t/db_dependent/Illrequests.t >@@ -893,7 +893,7 @@ subtest 'Checking out' => sub { > item_type => $itemtype->itemtype, > branchcode => '---' > }); >- } qr/^DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails/, >+ } qr/DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails/, > "Item creation fails on bad parameters"; > > is_deeply($form_stage_bad_branchcode->{value}->{errors}, { >diff --git a/t/db_dependent/Reports/Guided.t b/t/db_dependent/Reports/Guided.t >index e2143a6525..4352d48568 100644 >--- a/t/db_dependent/Reports/Guided.t >+++ b/t/db_dependent/Reports/Guided.t >@@ -257,7 +257,7 @@ subtest 'get_saved_reports' => sub { > warning_like {local $dbh->{RaiseError} = 0; ($sth, $errors) = execute_query( > 'SELECT surname FRM borrowers', # error in the query is intentional > 0, 10 ) } >- qr/^DBD::mysql::st execute failed: You have an error in your SQL syntax;/, >+ qr/DBD::mysql::st execute failed: You have an error in your SQL syntax;/, > "Wrong SQL syntax raises warning"; > ok( > defined($errors) && exists($errors->{queryerr}), >@@ -400,7 +400,7 @@ subtest 'Email report test' => sub { > > # for next test, we want to let execute_query capture any SQL errors > warning_like { local $dbh->{RaiseError} = 0; ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report2, module => $letter1->{module} , code => $letter1->{code} }) } >- qr/^DBD::mysql::st execute failed/, >+ qr/DBD::mysql::st execute failed/, > 'Error from bad report'; > is( $errors->[0]{FATAL}, 'REPORT_FAIL', "Bad report returns failure"); > >@@ -452,8 +452,8 @@ subtest 'nb_rows() tests' => sub { > # for next test, we want to let execute_query capture any SQL errors > > warning_like >- { local $dbh->{RaiseError} = 0; $nb_rows = nb_rows( $bad_query ) } >- qr/^DBD::mysql::st execute failed:/, >+ { $nb_rows = nb_rows( $bad_query ) } >+ qr/DBD::mysql::st execute failed:/, > 'Bad queries raise a warning'; > > is( $nb_rows, 0, 'nb_rows returns 0 on bad queries' ); >diff --git a/t/db_dependent/api/v1/acquisitions_orders.t b/t/db_dependent/api/v1/acquisitions_orders.t >index 01fe28a92a..c9c6194798 100644 >--- a/t/db_dependent/api/v1/acquisitions_orders.t >+++ b/t/db_dependent/api/v1/acquisitions_orders.t >@@ -222,7 +222,7 @@ subtest 'add() tests' => sub { > ->status_is(409) > ->json_has( '/error' => "Fails when trying to add an existing order_id") > ->json_like( '/conflict' => qr/(aqorders\.)?PRIMARY/ ); } >- qr/^DBD::mysql::st execute failed: Duplicate entry '(.*)' for key '(aqorders\.)?PRIMARY'/; >+ qr/DBD::mysql::st execute failed: Duplicate entry '(.*)' for key '(aqorders\.)?PRIMARY'/; > > $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/api/v1/libraries.t b/t/db_dependent/api/v1/libraries.t >index 4e82935f4b..c6e9cdffbe 100644 >--- a/t/db_dependent/api/v1/libraries.t >+++ b/t/db_dependent/api/v1/libraries.t >@@ -203,7 +203,7 @@ subtest 'add() tests' => sub { > ->status_is(409) > ->json_has( '/error' => "Fails when trying to add an existing library_id") > ->json_like( '/conflict' => qr/(branches\.)?PRIMARY/ ); } >- qr/^DBD::mysql::st execute failed: Duplicate entry '(.*)' for key '(branches\.)?PRIMARY'/; >+ qr/DBD::mysql::st execute failed: Duplicate entry '(.*)' for key '(branches\.)?PRIMARY'/; > > $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index 8321f2e4c0..a18d364dee 100644 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -160,7 +160,7 @@ subtest 'add() tests' => sub { > $t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) > ->status_is(409) > ->json_is('/error' => "Duplicate ID"); } >- qr/^DBD::mysql::st execute failed: Duplicate entry/; >+ qr/DBD::mysql::st execute failed: Duplicate entry/; > > $newpatron->{library_id} = $patron->branchcode; > >@@ -208,7 +208,7 @@ subtest 'add() tests' => sub { > ->status_is(409) > ->json_has( '/error', 'Fails when trying to POST duplicate cardnumber' ) > ->json_like( '/conflict' => qr/(borrowers\.)?cardnumber/ ); } >- qr/^DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(borrowers\.)?cardnumber'/; >+ qr/DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(borrowers\.)?cardnumber'/; > > $schema->storage->txn_rollback; > }; >@@ -287,7 +287,7 @@ subtest 'update() tests' => sub { > $t->put_ok("//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron) > ->status_is(400) > ->json_is('/error' => "Given library_id does not exist"); } >- qr/^DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails/; >+ qr/DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails/; > > # Restore the valid library_id > $newpatron->{library_id} = $patron_2->branchcode; >@@ -312,7 +312,7 @@ subtest 'update() tests' => sub { > ->status_is(409) > ->json_has( '/error', "Fails when trying to update to an existing cardnumber or userid") > ->json_like( '/conflict' => qr/(borrowers\.)?cardnumber/ ); } >- qr/^DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(borrowers\.)?cardnumber'/; >+ qr/DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(borrowers\.)?cardnumber'/; > > $newpatron->{ cardnumber } = $patron_1->id . $patron_2->id; > $newpatron->{ userid } = "user" . $patron_1->id.$patron_2->id; >diff --git a/t/db_dependent/api/v1/return_claims.t b/t/db_dependent/api/v1/return_claims.t >index fec56ba537..f0d8b1f24f 100644 >--- a/t/db_dependent/api/v1/return_claims.t >+++ b/t/db_dependent/api/v1/return_claims.t >@@ -93,7 +93,7 @@ subtest 'claim_returned() tests' => sub { > } > )->status_is(409) > } >- qr/^DBD::mysql::st execute failed: Duplicate entry/; >+ qr/DBD::mysql::st execute failed: Duplicate entry/; > > $issue->delete; > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22001
:
83230
|
83231
|
83232
|
98910
|
98911
|
98912
|
99589
|
99590
|
99591
|
101989
|
101990
|
101991
|
102070
|
102140
|
102147
| 102149 |
102150
|
102151
|
102152