App-Framework
view release on metacpan or search on metacpan
t/20-Feature-Config.t view on Meta::CPAN
my $DEBUG=0;
my $VERBOSE=0;
my $stdout="" ;
my $stderr="" ;
if (@ARGV)
{
$DEBUG = $ARGV[0] ;
$VERBOSE = $ARGV[0] ;
@ARGV = () ;
}
diag( "Testing config" );
my $read_dir = "t/config2" ;
my $write_dir = "t/config_wr" ;
my %expected = (
'dbg-namestuff' => "config2 a name",
debug => 56,
default => "config2 default",
default2 => "config2 b default",
default3 => "a-new-value",
log => "different log",
name => "this-is-a-test",
nomacro => 1,
) ;
my %expected_options = (
config => "20-Feature-Config.conf",
config_path => $read_dir,
config_write => undef,
config_writepath => $write_dir,
%expected,
) ;
my %single_sections = (
'server' => 1,
'snmp-trap' => 1,
) ;
my %sections = (
'server' => [
{
'port' => 32023,
'tick' => 5,
},
],
'snmp-trap' => [
{
'port' => 32161,
'logfile' => '/tmp/ate_snmp.log',
},
],
'tty' => [
{
name => 'SC2-1',
host => 'tty-server2',
port => 2011,
prompt => '/SC2-HWTC\s*>/i',
timeout => 90,
},
{
name => 'BBU-1',
host => 'tty-server2',
port => 2012,
prompt => '/(RSS|\-)\s*>/i',
timeout => 90,
},
{
name => 'SC2-2',
host => 'tty-server2',
port => 2013,
prompt => '/SC2-HWTC\s*>/i',
timeout => 90,
},
{
name => 'BBU-2',
host => 'tty-server2',
port => 2014,
prompt => '/(RSS|\-)\s*>/i',
timeout => 90,
},
],
'snmp' => [
{
name => 'CTU4-1',
host => 'ctu4-1',
},
{
name => 'CTU4-2',
host => 'ctu4-2',
},
{
name => 'CTU4-3',
host => 'ctu4-3',
},
{
name => 'CTU4-4',
host => 'ctu4-4',
},
],
) ;
plan tests =>
(scalar(keys %expected_options)) +
(2*scalar(keys %expected)) + scalar(keys %sections) + scalar(keys %single_sections) +
(2*scalar(keys %expected)) + scalar(keys %sections) + scalar(keys %single_sections);
## clear out write path
if (-d $write_dir)
{
foreach my $f (glob("$write_dir"))
{
unlink $f ;
}
rmdir $write_dir ;
}
## no run tests
my $app = App::Framework->new('exit_type'=>'die',
'feature_config' => {
'config' => {
'debug' => $DEBUG,
},
'options' => {
'debug' => $DEBUG,
},
},
) ;
@ARGV = (
'-name', 'this-is-a-test',
'-nomacro',
'-default3', 'a-new-value',
'-config_path', 't/config2',
'-config_writepath', 't/config_wr',
) ;
eval {$app->go()} ;
$@ =~ s/Died.*//m if $@ ;
( run in 1.081 second using v1.01-cache-2.11-cpan-6aa56a78535 )