Debian Codegraph @

t/04_plugins/14_logger/01_load.t

raw
1 use strict;
2 use warnings FATAL => 'all';
3 use File::Temp qw(tempdir);
4 use Test::More tests => 3;
5 use POE;
6 use POE::Component::IRC::State;
7 use POE::Component::IRC::Plugin::Logger;
8
9 my $log_dir = tempdir(CLEANUP => 1);
10
11 my $bot = POE::Component::IRC::State->spawn( plugin_debug => 1 );
12
13 POE::Session->create(
14 package_states => [
15 main => [ qw(_start irc_plugin_add irc_plugin_del) ],
16 ],
17 );
18
19 $poe_kernel->run();
20
21 sub _start {
22 $bot->yield(register => 'all');
23
24 my $plugin = POE::Component::IRC::Plugin::Logger->new( Path => $log_dir );
25 isa_ok($plugin, 'POE::Component::IRC::Plugin::Logger');
26
27 if (!$bot->plugin_add('TestPlugin', $plugin )) {
28 fail('plugin_add failed');
29 $bot->yield('shutdown');
30 }
31 }
32
33 sub irc_plugin_add {
34 my ($name, $plugin) = @_[ARG0, ARG1];
35 return if $name ne 'TestPlugin';
36
37 isa_ok($plugin, 'POE::Component::IRC::Plugin::Logger');
38
39 if (!$bot->plugin_del('TestPlugin') ) {
40 fail('plugin_del failed');
41 $bot->yield('shutdown');
42 }
43 }
44
45 sub irc_plugin_del {
46 my ($name, $plugin) = @_[ARG0, ARG1];
47 return if $name ne 'TestPlugin';
48
49 isa_ok($plugin, 'POE::Component::IRC::Plugin::Logger');
50 $bot->yield('shutdown');
51 }