Bugzilla – Attachment 160885 Details for
Bug 35536
Improve removal of Koha plugins in unit tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35536: Reorder rollbacks
Bug-35536-Reorder-rollbacks.patch (text/plain), 6.45 KB, created by
Kyle M Hall (khall)
on 2024-01-11 16:53:34 UTC
(
hide
)
Description:
Bug 35536: Reorder rollbacks
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-01-11 16:53:34 UTC
Size:
6.45 KB
patch
obsolete
>From 7be48ae9a4b0cdb1a2c562afd635bffcf40ecad4 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 14 Dec 2023 07:54:22 +0000 >Subject: [PATCH] Bug 35536: Reorder rollbacks > >Time to move all RemovePlugins calls BEFORE rollbacks. >Broken.t did not even include a transaction! Some modules >are removed there as well. > >Test plan: >Search for wrong order with: > grep -Pzo "txn_rollback;\n.*RemovePlugins" $(git grep -l RemovePlugins) > No occurrences left? Think of another grep :) >Check number of records in plugin_data/methods. >Repeat: prove $(git grep -l Koha::Plugin | grep -P "^t\/db") >And check number of records again. Same? > >Bonus: Apply TestMR plugin patch (marked DO NOT PUSH). >Run perl -MKoha::Plugins -e"Koha::Plugins->new->InstallPlugins". >Check plugin records in database. >Keep those records but remove last patch from git. >Run previous prove and verify no data changes since last check. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Koha/Plugins/BackgroundJob.t | 2 +- > .../Koha/Plugins/Barcode_transform_hooks.t | 2 +- > .../Plugins/Biblio_and_Items_plugin_hooks.t | 2 +- > t/db_dependent/Koha/Plugins/Broken.t | 26 +++++++++---------- > .../Koha/Plugins/Circulation_hooks.t | 2 +- > t/db_dependent/Koha/Plugins/Patron.t | 4 +-- > t/db_dependent/Koha/Plugins/authority_hooks.t | 2 +- > 7 files changed, 19 insertions(+), 21 deletions(-) > >diff --git a/t/db_dependent/Koha/Plugins/BackgroundJob.t b/t/db_dependent/Koha/Plugins/BackgroundJob.t >index a4c8e58e299..c5ccd3763f7 100755 >--- a/t/db_dependent/Koha/Plugins/BackgroundJob.t >+++ b/t/db_dependent/Koha/Plugins/BackgroundJob.t >@@ -84,6 +84,6 @@ subtest 'background_tasks() hooks tests' => sub { > > is_deeply( $tasks, $bj->core_types_to_classes, 'Only core mapping returned when plugins disabled' ); > >- $schema->storage->txn_rollback; > Koha::Plugins->RemovePlugins; >+ $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t b/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t >index 202f1bfdd9a..234f7d572f3 100755 >--- a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t >+++ b/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t >@@ -99,6 +99,6 @@ subtest 'patron_barcode_transform() and item_barcode_transform() hook tests' => > qr/Plugin error \(Test Plugin\): Exception 'Koha::Exception' thrown 'item_barcode_transform called with parameter: THISISATEST'/, > 'Koha::Item->store calls the item_barcode_transform hook'; > >- $schema->storage->txn_rollback; > Koha::Plugins->RemovePlugins; >+ $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t b/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t >index 1ca1d5116e2..7f818dfd487 100755 >--- a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t >+++ b/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t >@@ -83,6 +83,6 @@ subtest 'after_biblio_action() and after_item_action() hooks tests' => sub { > qr/after_biblio_action called with action: delete, id: $biblio_id/, > 'DelBiblio calls the hook with action=delete biblio_id passed'; > >- $schema->storage->txn_rollback; > Koha::Plugins->RemovePlugins; >+ $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/Koha/Plugins/Broken.t b/t/db_dependent/Koha/Plugins/Broken.t >index d6e58fda1e5..6db153db7ed 100755 >--- a/t/db_dependent/Koha/Plugins/Broken.t >+++ b/t/db_dependent/Koha/Plugins/Broken.t >@@ -15,15 +15,13 @@ > # with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >- >-use Test::More tests => 3; >-use Test::MockModule; >-use Test::Warn; >- > use File::Basename; >+use Test::More tests => 2; >+use Test::Warn; > > use t::lib::Mocks; >-use t::lib::TestBuilder; >+ >+use Koha::Database; > > BEGIN { > # Mock pluginsdir before loading Plugins module >@@ -31,17 +29,19 @@ BEGIN { > t::lib::Mocks::mock_config( 'pluginsdir', $path ); > > use_ok('Koha::Plugins'); >- use_ok('Koha::Plugins::Handler'); > } > >-my $schema = Koha::Database->new->schema; >-my $builder = t::lib::TestBuilder->new; >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; > > t::lib::Mocks::mock_config( 'enable_plugins', 1 ); > > my $plugins = Koha::Plugins->new; > >-warnings_are >- { $plugins->InstallPlugins; } >- [ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", >- "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ]; >+warnings_are { $plugins->InstallPlugins; } >+[ >+ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", >+ "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" >+]; >+ >+$schema->storage->txn_begin; >diff --git a/t/db_dependent/Koha/Plugins/Circulation_hooks.t b/t/db_dependent/Koha/Plugins/Circulation_hooks.t >index 02911a01c51..47ac5d58afa 100755 >--- a/t/db_dependent/Koha/Plugins/Circulation_hooks.t >+++ b/t/db_dependent/Koha/Plugins/Circulation_hooks.t >@@ -120,6 +120,6 @@ subtest 'after_circ_action() hook tests' => sub { > 'AddReturn calls the after_circ_action hook'; > }; > >- $schema->storage->txn_rollback; > Koha::Plugins->RemovePlugins; >+ $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/Koha/Plugins/Patron.t b/t/db_dependent/Koha/Plugins/Patron.t >index 363a2fa0e31..eb001c88815 100755 >--- a/t/db_dependent/Koha/Plugins/Patron.t >+++ b/t/db_dependent/Koha/Plugins/Patron.t >@@ -87,8 +87,6 @@ subtest 'check_password hook tests' => sub { > ok( $patron->set_password({ password => '4321' }), 'Patron password updated with good string' ); > ok( $patron->set_password({ password => 'explosion', skip_validation => 1}), 'Patron password updated via skip validation'); > >- $schema->storage->txn_rollback; > Koha::Plugins->RemovePlugins; >+ $schema->storage->txn_rollback; > }; >- >-1; >diff --git a/t/db_dependent/Koha/Plugins/authority_hooks.t b/t/db_dependent/Koha/Plugins/authority_hooks.t >index 464fb16262c..959795d2f89 100755 >--- a/t/db_dependent/Koha/Plugins/authority_hooks.t >+++ b/t/db_dependent/Koha/Plugins/authority_hooks.t >@@ -65,6 +65,6 @@ subtest 'after_authority_action hook' => sub { > qr/after_authority_action called with action: delete, id: $id/, > 'DelAuthority calls the hook with action=delete, id passed'; > >- $schema->storage->txn_rollback; > Koha::Plugins->RemovePlugins; >+ $schema->storage->txn_rollback; > }; >-- >2.30.2
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 35536
:
159804
|
159820
|
159821
|
159822
|
159823
|
159824
|
159825
|
159830
|
159839
|
159840
|
159841
|
159842
|
159843
|
159844
|
160024
|
160025
|
160026
|
160027
|
160028
|
160029
|
160030
|
160031
|
160032
|
160801
|
160802
|
160803
|
160804
|
160805
|
160806
|
160807
|
160808
|
160809
|
160817
|
160818
|
160819
|
160820
|
160821
|
160822
|
160823
|
160824
|
160825
|
160881
|
160882
|
160883
|
160884
| 160885 |
160886
|
160887
|
160888
|
160889
|
163701
|
163797