File: 04_console.t

package info (click to toggle)
libdancer-perl 1.3521%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,460 kB
  • sloc: perl: 7,436; xml: 2,211; sh: 54; makefile: 32; sql: 5
file content (36 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# this test makes sure the "console" logger send log messages to STDERR

use strict;
use warnings;
use Test::More import => ['!pass'];

use Dancer::ModuleLoader;
use Dancer;

plan skip_all => "Test::Output is needed for this test"
    unless Dancer::ModuleLoader->load('Test::Output');

plan tests => 8;

use_ok 'Dancer::Logger::Console';
my $l = Dancer::Logger::Console->new;

ok(defined($l), "logger is defined");
isa_ok($l, 'Dancer::Logger::Abstract');
isa_ok($l, 'Dancer::Logger::Console');

Test::Output::stderr_like( sub { $l->debug("debug message") }, 
    qr/\[\d+\] debug @.+> debug message in/,
    "debug  output is sent to STDERR");

Test::Output::stderr_like( sub { $l->warning("warning message") }, 
    qr/\[\d+\]  warn @.+> warning message in/,
    "warning log output is sent to STDERR");

Test::Output::stderr_like( sub { $l->error("error message") }, 
    qr/\[\d+\] error @.+> error message in/,
    "error output is sent to STDERR");

Test::Output::stderr_like( sub { $l->info("info message") }, 
    qr/\[\d+\]  info @.+> info message in/,
    "info output is sent to STDERR");