File Coverage

File:t/bot-irc-api.t
Coverage:97.2%

linestmtbrancondsubpodtimecode
1
1
1
1
133593
12
63
use strict;
2
1
1
1
13
9
63
use warnings;
3
4
1
1
1
1347
23724
11
use Test::Lib;
5
1
1
1
15323
2176049
13
use Test::Most;
6
7
1
1
1
1066068
49
19964
use constant MODULE => 'Bot::IRC';
8
9
1
1
1
1
1
196
34701
21
7
67
BEGIN { use_ok(MODULE); }
10
1
481985
require_ok(MODULE);
11
12
1
1
589
43
throws_ok( sub { MODULE->new }, qr|connect/server not provided|, MODULE . '->new dies' );
13
1
29
lives_ok( sub { MODULE->new(
14    connect => { server => 'irc.perl.org' }
15
1
634
) }, MODULE . '->new( connect => { server => $server } )' );
16
17
1
253
my $settings = {
18    spawn  => 3,
19    daemon => {
20        name        => 'bot',
21        lsb_sdesc   => 'IRC Bot',
22        pid_file    => 'bot.pid',
23        stderr_file => 'bot.err',
24        stdout_file => 'bot.log',
25    },
26    connect => {
27        server => 'irc.perl.org',
28        port   => '6667',
29        nick   => 'bot',
30        name   => 'Yet Another IRC Bot',
31        join   => [ '#test', '#perl' ],
32        ssl    => 0,
33    },
34};
35
36
1
6
my $bot;
37
38
1
1
10
24
lives_ok( sub { $bot = MODULE->new(%$settings) }, MODULE . '->new(@config)' );
39
40
1
26
throws_ok( sub { $bot = MODULE->new(
41    %$settings,
42    plugins => ['MissingPlugin'],
43
1
218
) }, qr/Unable to find or properly load/, MODULE . '->new(@config) + missing plugin' );
44
45
1
30
lives_ok( sub { $bot = MODULE->new(
46    %$settings,
47    plugins => ['SimpleTestPlugin'],
48
1
621
) }, MODULE . '->new(@config) + empty plugin' );
49
50lives_ok( sub {
51
1
29
    $bot->reload('SimpleTestPlugin')
52
1
289
}, MODULE . '->reload SimpleTestPlugin' );
53
54lives_ok( sub {
55
1
27
    $bot->hook( {}, sub {}, { priority => 50 } )
56
1
216
}, MODULE . '->hook' );
57
58lives_ok( sub {
59    $bot->hooks(
60        [ {}, sub {} ],
61
1
26
        [ {}, sub {} ],
62    )
63
1
200
}, MODULE . '->hooks' );
64
65lives_ok( sub {
66
1
23
    $bot->helps( term => 'Description.', term2 => 'Description two.' )
67
1
184
}, MODULE . '->hooks' );
68
69lives_ok( sub {
70    $bot->tick( 10, sub {} )
71
1
1
199
24
}, MODULE . '->tick' );
72
73lives_ok( sub {
74    $bot->ticks(
75        [ 10, sub {} ],
76
1
26
        [ 10, sub {} ],
77    )
78
1
182
}, MODULE . '->ticks' );
79
80lives_ok( sub {
81    $bot->subs(
82        name0 => sub {},
83        name1 => sub {},
84    )
85
1
1
186
27
}, MODULE . '->ticks' );
86
87lives_ok( sub {
88
1
22
    $bot->register( qw( Alpha Beta Delta ) )
89
1
229
}, MODULE . '->ticks' );
90
91
1
196
done_testing;