Bugzilla – Attachment 65012 Details for
Bug 18826
REST API tests do not clean up
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18826: rollback transaction for api tests
Bug-18826-rollback-transaction-for-api-tests.patch (text/plain), 3.06 KB, created by
Jonathan Druart
on 2017-07-12 20:28:06 UTC
(
hide
)
Description:
Bug 18826: rollback transaction for api tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-07-12 20:28:06 UTC
Size:
3.06 KB
patch
obsolete
>From 73232c060684517c66045f6f1ddf08094d338047 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 12 Jul 2017 17:24:24 -0300 >Subject: [PATCH] Bug 18826: rollback transaction for api tests > >The holds.t tests for the REST api do no rollback properly and modify >the DB (no cleanup). >This comes from a bug caused by SessionStorage = mysql (default) > >The error is: > "rollback ineffective with AutoCommit enabled" > >Test plan: > select count(*) from borrowers; > prove t/db_dependent/api/v1/holds.t > select count(*) from borrowers; >=> The number of entry must be the same before and after the tests have >been executed >--- > t/db_dependent/api/v1/holds.t | 14 +++++++++----- > t/db_dependent/api/v1/patrons.t | 8 ++++---- > 2 files changed, 13 insertions(+), 9 deletions(-) > >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index c7ec7f8880..4e39473191 100644 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -20,6 +20,7 @@ use Modern::Perl; > use Test::More tests => 4; > use Test::Mojo; > use t::lib::TestBuilder; >+use t::lib::Mocks; > > use DateTime; > >@@ -31,11 +32,14 @@ use Koha::Biblios; > use Koha::Items; > use Koha::Patrons; > >+my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new(); > >-my $dbh = C4::Context->dbh; >-$dbh->{AutoCommit} = 0; >-$dbh->{RaiseError} = 1; >+$schema->storage->txn_begin; >+ >+# FIXME: sessionStorage defaults to mysql, but it seems to break transaction handling >+# this affects the other REST api tests >+t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' ); > > $ENV{REMOTE_ADDR} = '127.0.0.1'; > my $t = Test::Mojo->new('Koha::REST::V1'); >@@ -113,6 +117,7 @@ my $itemnumber = create_item($biblionumber, 'TEST000001'); > my $biblionumber2 = create_biblio('RESTful Web APIs'); > my $itemnumber2 = create_item($biblionumber2, 'TEST000002'); > >+my $dbh = C4::Context->dbh; > $dbh->do('DELETE FROM reserves'); > $dbh->do('DELETE FROM issuingrules'); > $dbh->do(q{ >@@ -303,8 +308,7 @@ subtest "Test endpoints with permission" => sub { > ->json_like('/error', qr/tooManyReserves/); > }; > >- >-$dbh->rollback; >+$schema->storage->txn_rollback; > > sub create_biblio { > my ($title) = @_; >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index 6b3f51faf9..705a2f8d7b 100644 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -20,6 +20,7 @@ use Modern::Perl; > use Test::More tests => 21; > use Test::Mojo; > use t::lib::TestBuilder; >+use t::lib::Mocks; > > use C4::Auth; > use C4::Context; >@@ -27,11 +28,10 @@ use C4::Context; > use Koha::Database; > use Koha::Patron; > >+my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new(); > >-my $dbh = C4::Context->dbh; >-$dbh->{AutoCommit} = 0; >-$dbh->{RaiseError} = 1; >+$schema->storage->txn_begin; > > $ENV{REMOTE_ADDR} = '127.0.0.1'; > my $t = Test::Mojo->new('Koha::REST::V1'); >@@ -131,4 +131,4 @@ $t->request_ok($tx) > ->json_is('/surname' => $borrower->{ surname }) > ->json_is('/lost' => 1 ); > >-$dbh->rollback; >+$schema->storage->txn_rollback; >-- >2.11.0
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 18826
:
65012
|
65143
|
65177
|
65178