From 0ce284e946bdb0358e6fa33f1b7ecb158e6ad4a5 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Wed, 12 Jul 2017 15:09:18 +0300 Subject: [PATCH] Bug 16825: (squashable) Fix test cleanup issues Roll back failed at the end of the test. Apply this patch to fix the issue. To test: 1. prove t/db_dependent/api/v1/items.t 2. Check your database to make sure nothing persists after the test --- t/db_dependent/api/v1/items.t | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/api/v1/items.t b/t/db_dependent/api/v1/items.t index 0b97313..9b3d2e6 100644 --- a/t/db_dependent/api/v1/items.t +++ b/t/db_dependent/api/v1/items.t @@ -21,6 +21,7 @@ use Modern::Perl; use Test::More tests => 12; use Test::Mojo; +use t::lib::Mocks; use t::lib::TestBuilder; use C4::Auth; @@ -32,11 +33,14 @@ use Koha::Database; use Koha::Patron; use Koha::Items; +my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new(); -my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; +# 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' ); + +$schema->storage->txn_begin; $ENV{REMOTE_ADDR} = '127.0.0.1'; my $t = Test::Mojo->new('Koha::REST::V1'); @@ -99,7 +103,7 @@ $t->request_ok($tx) ->json_is('/biblionumber' => $biblionumber) ->json_is('/itemnotes_nonpublic' => $item->{itemnotes_nonpublic}); -$dbh->rollback; +$schema->storage->txn_rollback; sub create_session { my (@borrowers) = @_; -- 2.7.4