Log-Mini/t/01_logger_builder.t

44 lines
938 B
Perl
Raw Permalink Normal View History

2019-02-21 22:30:49 +03:00
use lib 'lib';
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use File::Temp;
2019-02-21 22:30:49 +03:00
use Log::Mini;
2023-03-17 18:29:38 +03:00
2019-02-21 22:30:49 +03:00
subtest 'creates stderr logger' => sub {
2019-02-21 23:23:53 +03:00
my $logger = Log::Mini->new('stderr');
2019-02-21 22:30:49 +03:00
2023-03-17 18:29:38 +03:00
isa_ok $logger, 'Log::Mini::Logger::STDERR';
2019-02-21 22:30:49 +03:00
};
2019-04-12 01:01:37 +03:00
subtest 'creates null logger' => sub {
my $logger = Log::Mini->new('null');
2023-03-17 18:29:38 +03:00
isa_ok $logger, 'Log::Mini::Logger::NULL';
2019-04-12 01:01:37 +03:00
};
2019-02-21 22:30:49 +03:00
subtest 'creates file logger' => sub {
2023-03-17 18:29:38 +03:00
my $file = File::Temp->new;
my $logger = Log::Mini->new('file' => $file->filename);
2019-02-21 22:30:49 +03:00
2023-03-17 18:29:38 +03:00
isa_ok $logger, 'Log::Mini::Logger::FILE';
};
subtest 'return STDERR on no logger name given' => sub {
my $logger = Log::Mini->new();
isa_ok $logger, 'Log::Mini::Logger::STDERR';
2019-02-21 22:30:49 +03:00
};
2023-03-17 18:29:38 +03:00
subtest 'throw on unknown logger adapter' => sub {
like(
exception { Log::Mini->new('unknown'); },
qr/^Failed to load adapter: unknown, .*/,
"the code died on unknown adapter",
);
2019-02-21 22:30:49 +03:00
};
2023-03-17 18:29:38 +03:00
done_testing;