BEGIN {
use_ok(
'Bot::Cobalt::Conf::File::Plugins'
);
use_ok(
'Bot::Cobalt::Conf::File::PerPlugin'
);
}
my
$etcdir
= File::Spec->catdir(
'share'
,
'etc'
);
my
$plug_cf_path
= File::Spec->catfile(
$etcdir
,
'plugins.conf'
);
my
$plugcf
= new_ok(
'Bot::Cobalt::Conf::File::Plugins'
=> [
cfg_path
=>
$plug_cf_path
,
etcdir
=>
$etcdir
,
debug
=> 1,
],
);
isa_ok(
$plugcf
,
'Bot::Cobalt::Conf::File'
);
ok(
$plugcf
->validate,
'validate()'
);
ok(
ref
$plugcf
->list_plugins eq
'ARRAY'
,
'list_plugins() isa ARRAY'
);
for
my
$alias
(@{
$plugcf
->list_plugins }) {
isa_ok(
$plugcf
->plugin(
$alias
),
'Bot::Cobalt::Conf::File::PerPlugin'
);
ok(
$plugcf
->plugin(
$alias
)->module,
"module() - $alias"
);
}
ok(
ref
$plugcf
->plugin(
'IRC'
)->opts eq
'HASH'
,
"opts() isa HASH"
);
ok(
$plugcf
->plugin(
'Alarmclock'
)->opts->{LevelRequired},
"opts() merged from plugins.conf"
);
ok(
$plugcf
->plugin(
'IRC'
)->priority,
"priority()"
);
ok(
$plugcf
->plugin(
'IRC'
)->config_file,
"config_file()"
);
ok(
$plugcf
->plugin(
'IRC'
)->autoload,
"autoload()"
);
ok(
$plugcf
->plugin(
'Alarmclock'
)->reload_conf,
"reload_conf()"
);
ok(
$plugcf
->plugin(
'Alarmclock'
)->opts->{LevelRequired},
"opts() after reload_conf()"
);
ok(
$plugcf
->clear_plugin(
'Alarmclock'
),
'clear_plugin()'
);
ok( !
$plugcf
->plugin(
'Alarmclock'
),
'clear_plugin() was successful'
);
ok(
$plugcf
->load_plugin(
'Alarmclock'
),
'load_plugin()'
);
ok(
$plugcf
->plugin(
'Alarmclock'
)->opts->{LevelRequired},
"opts() after load_plugin"
);
my
$new_plug
= new_ok(
'Bot::Cobalt::Conf::File::PerPlugin'
=> [
module
=>
'Example::Module'
,
],
);
ok(
$plugcf
->install_plugin(
'Test'
,
$new_plug
),
'install_plugin()'
);
ok(
$plugcf
->plugin(
'Test'
),
'install_plugin() seems successful'
);
is(
$plugcf
->plugin(
'Test'
)->module,
'Example::Module'
,
'module() after install_plugin()'
);
done_testing