File: munin_node_configure_debug.t

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (36 lines) | stat: -rw-r--r-- 854 bytes parent folder | download | duplicates (11)
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
use strict;
use warnings;

use Test::More tests => 3;

use Munin::Node::Configure::Debug;
use Munin::Node::Config;

my $config = Munin::Node::Config->instance;


{
    open my $fh, '>', \(my $debug_message) or die "Unable to open scalar-backed filehandle: $!";

    $config->{DEBUG} = 0;

    my $old_fh = select $fh;
    DEBUG('error message');
    select $old_fh;

    is($debug_message, undef, 'No debug message printed when DEBUG is not enabled');
}
{
    open my $fh, '>', \(my $debug_message) or die "Unable to open scalar-backed filehandle: $!";

    $config->{DEBUG} = 1;

    my $old_fh = select $fh;
    DEBUG('debug message');
    select $old_fh;

    ok($debug_message, 'Debug message was printed when DEBUG is enabled') or next;
    is($debug_message, "# debug message\n", 'Debug message is correctly formatted');
}

# vim: ts=4 : sw=4 : et