Bug 18289

Summary: Fix t/Prices.t having a Test::DBIx::Class cache issue
Product: Koha Reporter: Olli-Antti Kivilahti <olli-antti.kivilahti>
Component: Test SuiteAssignee: Olli-Antti Kivilahti <olli-antti.kivilahti>
Status: CLOSED FIXED QA Contact: Galen Charlton <gmcharlt>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, mtj, tomascohen, veron
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18288
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18287
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 18226    
Bug Blocks:    
Attachments: Bug 18289 - Fix t/Prices.t having a Test::DBIx::Class cache issue
Bug 18289 - Fix t/Prices.t having a Test::DBIx::Class cache issue

Description Olli-Antti Kivilahti 2017-03-16 19:28:55 UTC
REPLICATE ISSUE:

perl t/Prices.t -> fails

AFTER THIS PATCH AND DEPENDENCIES:

perl t/Prices.t -> OK
Comment 1 Olli-Antti Kivilahti 2017-03-16 19:29:53 UTC
Created attachment 61190 [details] [review]
Bug 18289 - Fix t/Prices.t having a Test::DBIx::Class cache issue

REPLICATE ISSUE:

perl t/Prices.t -> fails

AFTER THIS PATCH AND DEPENDENCIES:

perl t/Prices.t -> OK
Comment 2 Marc Véron 2017-03-22 10:44:47 UTC
It seems that it depends on 18226, not 18266.
(like dependencies of 18282 and 18288)

Changed dependency as appropriate.
Comment 3 Jonathan Druart 2017-05-23 20:06:25 UTC
I confirm that this fixes the tests on jenkins.

diff --git a/Koha/Database.pm b/Koha/Database.pm
index df259c5..f8a2fba 100644
--- a/Koha/Database.pm
+++ b/Koha/Database.pm
@@ -215,6 +215,11 @@ sub restore_schema {
     # return something, then this function should, too.
 }
 
+sub flush_schema_cache {
+    delete $database->{schema};
+    return 1;
+}
+
 =head2 EXPORT
 
 None by default.
diff --git a/t/Prices.t b/t/Prices.t
index f89c7f6..68dc788 100644
--- a/t/Prices.t
+++ b/t/Prices.t
@@ -29,6 +29,7 @@ use Test::DBIx::Class {
 
 my $db = Test::MockModule->new('Koha::Database');
 $db->mock( _new_schema => sub { return Schema(); } );
+Koha::Database::flush_schema_cache();
 
 fixtures_ok [
     Currency => [
Comment 4 Tomás Cohen Arazi 2017-05-24 13:54:51 UTC
(In reply to Jonathan Druart from comment #3)
> I confirm that this fixes the tests on jenkins.

The way to reproduce this in kohadevbox (or the like) is to stop memcached before running the tests.

And this patchset clearly fixes it!
Comment 5 Jonathan Druart 2017-06-05 20:45:30 UTC
Created attachment 64002 [details] [review]
Bug 18289 - Fix t/Prices.t having a Test::DBIx::Class cache issue

REPLICATE ISSUE:

perl t/Prices.t -> fails

AFTER THIS PATCH AND DEPENDENCIES:

perl t/Prices.t -> OK

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Jonathan Druart 2017-06-05 20:46:15 UTC
Trivial, skipping QA.
Comment 7 Jonathan Druart 2017-06-05 20:57:28 UTC
Pushed to master for 17.11, thanks to everybody involved!
Comment 8 Fridolin Somers 2017-06-13 07:31:15 UTC
Enhancement not pushed to 17.05.x