Bugzilla – Attachment 159817 Details for
Bug 35507
Fix handling plugins in unit tests causing random failures on Jenkins
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35507: Plugins.t - Mock SessionStorage, remove KitchenSink
Bug-35507-Pluginst---Mock-SessionStorage-remove-Ki.patch (text/plain), 4.26 KB, created by
Jonathan Druart
on 2023-12-14 07:43:26 UTC
(
hide
)
Description:
Bug 35507: Plugins.t - Mock SessionStorage, remove KitchenSink
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-12-14 07:43:26 UTC
Size:
4.26 KB
patch
obsolete
>From f3271d71e3390d3bc5379a23f794dc7dab794f04 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 12 Dec 2023 14:07:49 +0000 >Subject: [PATCH] Bug 35507: Plugins.t - Mock SessionStorage, remove > KitchenSink > >Removing the CGI::Session behavior to auto-commit by mocking >SessionStorage makes that the $plugin->test_template does no >longer commit. > >Since KitchenSink includes a CREATE TABLE, removing that code >removes the second implicit commit. We might move that code >to its own script? > >Adds a missing rollback too at the end. > >Test plan: >Run prove t/db_dependent/Koha/Plugins/Plugins.t >Verify that no records got added to plugin_data/methods table. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Koha/Plugins/Plugins.t | 45 +++------------------------ > 1 file changed, 4 insertions(+), 41 deletions(-) > >diff --git a/t/db_dependent/Koha/Plugins/Plugins.t b/t/db_dependent/Koha/Plugins/Plugins.t >index a629bf0123f..955712bfd03 100755 >--- a/t/db_dependent/Koha/Plugins/Plugins.t >+++ b/t/db_dependent/Koha/Plugins/Plugins.t >@@ -16,7 +16,6 @@ > > use Modern::Perl; > >-use Archive::Extract; > use CGI; > use Cwd qw(abs_path); > use File::Basename; >@@ -25,7 +24,7 @@ use File::Temp qw( tempdir tempfile ); > use FindBin qw($Bin); > use Module::Load::Conditional qw(can_load); > use Test::MockModule; >-use Test::More tests => 62; >+use Test::More tests => 50; > use Test::Warn; > > use C4::Context; >@@ -48,6 +47,8 @@ BEGIN { > > my $schema = Koha::Database->new->schema; > >+t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' ); >+ > subtest 'call() tests' => sub { > > plan tests => 4; >@@ -318,45 +319,6 @@ is( scalar grep( /^Test Plugin$/, @names), 0, "GetPlugins does not found disable > @names = map { $_->get_metadata()->{'name'} } @plugins; > is( scalar grep( /^Test Plugin$/, @names), 1, "With all param, GetPlugins found disabled Test Plugin" ); > >-for my $pass ( 1 .. 2 ) { >- my $plugins_dir; >- my $module_name = 'Koha::Plugin::Com::ByWaterSolutions::KitchenSink'; >- my $pm_path = 'Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm'; >- if ( $pass == 1 ) { >- my $plugins_dir1 = tempdir( CLEANUP => 1 ); >- t::lib::Mocks::mock_config('pluginsdir', $plugins_dir1); >- $plugins_dir = $plugins_dir1; >- push @INC, $plugins_dir1; >- } else { >- my $plugins_dir1 = tempdir( CLEANUP => 1 ); >- my $plugins_dir2 = tempdir( CLEANUP => 1 ); >- t::lib::Mocks::mock_config('pluginsdir', [ $plugins_dir2, $plugins_dir1 ]); >- $plugins_dir = $plugins_dir2; >- pop @INC; >- push @INC, $plugins_dir2; >- push @INC, $plugins_dir1; >- } >- my $full_pm_path = $plugins_dir . '/' . $pm_path; >- >- my $ae = Archive::Extract->new( archive => "$Bin/KitchenSinkPlugin.kpz", type => 'zip' ); >- unless ( $ae->extract( to => $plugins_dir ) ) { >- warn "ERROR: " . $ae->error; >- } >- use_ok('Koha::Plugin::Com::ByWaterSolutions::KitchenSink'); >- $plugin = Koha::Plugin::Com::ByWaterSolutions::KitchenSink->new({ enable_plugins => 1}); >- my $table = $plugin->get_qualified_table_name( 'mytable' ); >- >- ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" ); >- $INC{$pm_path} = $full_pm_path; # FIXME I do not really know why, but if this is moved before the $plugin constructor, it will fail with Can't locate object method "new" via package "Koha::Plugin::Com::ByWaterSolutions::KitchenSink" >- warning_is { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); } undef; >- ok( -f $full_pm_path, "Koha::Plugins::Handler::delete works correctly (pass $pass)" ); >- Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 }); >- my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' ); >- my $info = $sth->fetchall_arrayref; >- is( @$info, 0, "Table $table does no longer exist" ); >- ok( !( -f $full_pm_path ), "Koha::Plugins::Handler::delete works correctly (pass $pass)" ); >-} >- > subtest 'output and output_html tests' => sub { > > plan tests => 6; >@@ -445,3 +407,4 @@ subtest 'new() tests' => sub { > }; > > Koha::Plugins::Methods->delete; >+$schema->storage->txn_rollback; >-- >2.34.1
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 35507
:
159670
|
159739
|
159744
|
159745
|
159801
|
159802
|
159803
|
159817
|
159818
|
159846
|
159847
|
159848
|
159849
|
159850
|
159860
|
159861
|
159862