File: errlog.t

package info (click to toggle)
libmojolicious-plugin-cgi-perl 0.36-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 208 kB
  • ctags: 17
  • sloc: perl: 300; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 747 bytes parent folder | download
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
use t::Helper;

unlink 't/err.log';

my $app = Mojolicious->new;
my $t   = Test::Mojo->new($app);
my ($s, @err);

$app->plugin(CGI => {route => '/err', script => cgi_script('errlog')});
$app->log->on(
  message => sub {
    my ($log, $level, $message) = @_;
    push @err, $message if $level eq 'warn';
  }
);

$t->get_ok('/err');
like $err[0], qr{\[CGI:errlog:\d+\] yikes! at .*errlog line 4}, 'logged stderr';

$app = Mojolicious->new;
$t   = Test::Mojo->new($app);

$app->plugin(CGI => {route => '/err', script => cgi_script('errlog'), errlog => 't/err.log'});

$t->get_ok('/err');
$s = -s 't/err.log';
ok $s, 't/err.log has data';

$t->get_ok('/err');
ok -s 't/err.log' >= $s * 2, 't/err.log has more data';

unlink 't/err.log';
done_testing;