diff options
author | doy <doy@tozt.net> | 2008-12-01 23:24:07 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2008-12-01 23:24:07 -0500 |
commit | de1939e565da64f70c0b2e3f558493fd5df8701c (patch) | |
tree | d9e2ccf11ace6b35807188bd0ff2b9711101681d /t/003-errors.t | |
parent | 8c6449a2d99ba53b1823d333319c327ee2eb7e7d (diff) | |
download | log-dispatch-channels-de1939e565da64f70c0b2e3f558493fd5df8701c.tar.gz log-dispatch-channels-de1939e565da64f70c0b2e3f558493fd5df8701c.zip |
finish up tests
Diffstat (limited to 't/003-errors.t')
-rw-r--r-- | t/003-errors.t | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/t/003-errors.t b/t/003-errors.t new file mode 100644 index 0000000..6c8cc03 --- /dev/null +++ b/t/003-errors.t @@ -0,0 +1,29 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use lib 't/lib'; +use Test::More tests => 3; +use Log::Dispatch::Channels; +use Log::Dispatch::Null; + +my $logger = Log::Dispatch::Channels->new; +for my $channel (1..3) { + $logger->add_channel($channel); + $logger->add(Log::Dispatch::Null->new(name => $channel, + min_level => 'debug'), + channels => $channel); +} +my $warnings = ''; +$SIG{__WARN__} = sub { $warnings .= $_[0] }; +$logger->add_channel(1); +like($warnings, qr/^Channel 1 already exists!/, + "correct warning when replacing a channel"); +$warnings = ''; +$logger->add(Log::Dispatch::Null->new(name => 1, min_level => 'debug')); +like($warnings, qr/^Output 1 already exists!/, + "correct warning when replacing an output"); + +$warnings = ''; +$logger->log(channels => 4, message => 'test', level => 'debug'); +like($warnings, qr/^Channel 4 doesn't exist/, + "correct warning when forwarding to a nonexistant channel"); |