From de1939e565da64f70c0b2e3f558493fd5df8701c Mon Sep 17 00:00:00 2001 From: doy Date: Mon, 1 Dec 2008 23:24:07 -0500 Subject: finish up tests --- t/003-errors.t | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 t/003-errors.t (limited to 't/003-errors.t') 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"); -- cgit v1.2.3-54-g00ecf