Bugzilla – Attachment 103306 Details for
Bug 25172
Koha::Logger init is failing silently
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25172: Adjust tests
Bug-25172-Adjust-tests.patch (text/plain), 2.90 KB, created by
Martin Renvoize (ashimema)
on 2020-04-20 14:51:20 UTC
(
hide
)
Description:
Bug 25172: Adjust tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-04-20 14:51:20 UTC
Size:
2.90 KB
patch
obsolete
>From 19d9b0dc9d503f64c8fa5abaf4ac3dabfff72e3c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 16 Apr 2020 16:50:50 +0200 >Subject: [PATCH] Bug 25172: Adjust tests > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/Logger.t | 41 ++++++++++++++++++----------------------- > 1 file changed, 18 insertions(+), 23 deletions(-) > >diff --git a/t/Logger.t b/t/Logger.t >index 1a1d412666..a2a0cc58b8 100644 >--- a/t/Logger.t >+++ b/t/Logger.t >@@ -19,30 +19,23 @@ use Modern::Perl; > > use C4::Context; > use Koha::Logger; >+use t::lib::Mocks; > > use File::Temp qw/tempfile/; >-use Test::MockModule; > use Test::More tests => 1; > use Test::Warn; > > subtest 'Test01 -- Simple tests for Koha::Logger' => sub { >- plan tests => 8; >- test01(); >-}; >- >-sub test01 { >+ plan tests => 6; > > my $ret; >- my $mContext = new Test::MockModule('C4::Context'); >- $mContext->mock( 'config', sub { return; } ); >+ t::lib::Mocks::mock_config('log4perl_conf', undef); > >- my $logger= Koha::Logger->get; >- is( exists $logger->{logger}, '', 'No log4perl config'); >- my $d= $logger->debug('Message 1'); >- is( $d, undef, 'No return value for debug call'); >+ eval { Koha::Logger->get }; >+ ok( $@, 'Logger did not init correctly without config'); > > my $log = mytempfile(); >- my $conf = mytempfile( <<"HERE" >+ my $config_file = mytempfile( <<"HERE" > log4perl.logger.intranet = WARN, INTRANET > log4perl.appender.INTRANET=Log::Log4perl::Appender::File > log4perl.appender.INTRANET.filename=$log >@@ -51,21 +44,23 @@ log4perl.appender.INTRANET.layout=PatternLayout > log4perl.appender.INTRANET.layout.ConversionPattern=[%d] [%p] %m %l %n > HERE > ); >- $mContext->mock( 'config', sub { return $conf; } ); >- $logger= Koha::Logger->get({ interface => 'intranet' }); >+ >+ t::lib::Mocks::mock_config('log4perl_conf', $config_file); >+ >+ system("chmod 400 $log"); >+ eval { Koha::Logger->get }; >+ ok( $@, 'Logger did not init correctly without permission'); >+ >+ system("chmod 700 $log"); >+ my $logger= Koha::Logger->get({ interface => 'intranet' }); > is( exists $logger->{logger}, 1, 'Log4perl config found'); >- is( $logger->warn('Message 2'), 1, 'Message 2 returned a value' ); >+ is( $logger->warn('Message 1'), 1, '->warn returned a value' ); > warning_is { $ret = $logger->catastrophe } > "ERROR: Unsupported method catastrophe", > "Undefined method raises warning"; > is( $ret, undef, "'catastrophe' method undefined"); >- system("chmod 400 $log"); >- warnings_are { $ret = $logger->warn('Message 3') } >- [ "Log file not writable for log4perl", >- "warn: Message 3" ], >- "Warnings raised if log file is not writeable"; >- is( $ret, undef, 'Message 3 returned undef' ); >-} >+ >+}; > > sub mytempfile { > my ( $fh, $fn ) = tempfile( SUFFIX => '.logger.test', UNLINK => 1 ); >-- >2.20.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 25172
:
103088
|
103089
|
103090
|
103091
|
103300
|
103301
|
103302
|
103303
|
103304
|
103305
|
103306
|
103307
|
103310
|
103391
|
103392
|
103393
|
103394
|
103395
|
103485