Bug 18289 - Fix t/Prices.t having a Test::DBIx::Class cache issue
Summary: Fix t/Prices.t having a Test::DBIx::Class cache issue
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Olli-Antti Kivilahti
QA Contact: Galen Charlton
URL:
Keywords:
Depends on: 18226
Blocks:
  Show dependency treegraph
 
Reported: 2017-03-16 19:28 UTC by Olli-Antti Kivilahti
Modified: 2018-06-04 20:10 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 18289 - Fix t/Prices.t having a Test::DBIx::Class cache issue (742 bytes, patch)
2017-03-16 19:29 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review
Bug 18289 - Fix t/Prices.t having a Test::DBIx::Class cache issue (823 bytes, patch)
2017-06-05 20:45 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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