mirror of
https://github.com/duncs/clusterssh.git
synced 2025-04-20 16:59:06 +00:00
Further work on config module
This commit is contained in:
parent
3fedc40eaf
commit
5fb98fc796
4 changed files with 47 additions and 5 deletions
|
@ -141,13 +141,13 @@ sub parse_config_file {
|
|||
my ( $key, $value ) = ( $1, $2 );
|
||||
if ( defined $key && defined $value ) {
|
||||
$read_config{$key} = $value;
|
||||
logmsg( 3, "$key=$value" );
|
||||
$self->debug( 3, "$key=$value" );
|
||||
}
|
||||
}
|
||||
close(CFG);
|
||||
|
||||
# tidy up entries, just in case
|
||||
$read_config{terminal_font} =~ s/['"]//g;
|
||||
$read_config{terminal_font} =~ s/['"]//g if($read_config{terminal_font});
|
||||
|
||||
$self->validate_args(%read_config);
|
||||
}
|
||||
|
|
36
t/15config.t
36
t/15config.t
|
@ -81,6 +81,7 @@ Readonly::Hash my %default_config => {
|
|||
my %expected = %default_config;
|
||||
is_deeply( $config, \%expected, 'default config is correct' );
|
||||
|
||||
$config = App::ClusterSSH::Config->new();
|
||||
trap {
|
||||
$config = $config->validate_args(
|
||||
whoops => 'not there',
|
||||
|
@ -97,6 +98,7 @@ is_deeply(
|
|||
[ 'doesnt_exist', 'whoops' ],
|
||||
'Picked up unknown config array'
|
||||
);
|
||||
isa_ok( $config, "App::ClusterSSH::Config" );
|
||||
|
||||
$expected{extra_cluster_file} = '/etc/filename';
|
||||
$expected{rsh_args} = 'some args';
|
||||
|
@ -109,8 +111,10 @@ trap {
|
|||
);
|
||||
};
|
||||
is( $trap->die, undef, 'validated ok' );
|
||||
isa_ok( $config, "App::ClusterSSH::Config" );
|
||||
is_deeply( $config, \%expected, 'default config is correct' );
|
||||
|
||||
$config = App::ClusterSSH::Config->new();
|
||||
%expected = %default_config;
|
||||
|
||||
my $file = "$Bin/$Script.doesntexist";
|
||||
|
@ -123,4 +127,36 @@ is( $trap->die,
|
|||
'got correct error message'
|
||||
);
|
||||
|
||||
$file = "$Bin/$Script.file1";
|
||||
note("using $file");
|
||||
$config = App::ClusterSSH::Config->new();
|
||||
%expected = %default_config;
|
||||
$expected{screen_reserve_left}=100;
|
||||
$expected{screen_reserve_right}=100;
|
||||
$expected{screen_reserve_top}=100;
|
||||
$expected{screen_reserve_bottom}=160;
|
||||
trap {
|
||||
$config = $config->parse_config_file( $file, );
|
||||
};
|
||||
is( $trap->leaveby, 'return', 'returned ok' );
|
||||
is( $trap->die, undef, 'returned ok' );
|
||||
isa_ok( $config, "App::ClusterSSH::Config" );
|
||||
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
||||
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
||||
is_deeply( $config, \%expected, 'amended config is correct' );
|
||||
|
||||
$file = "$Bin/$Script.file2";
|
||||
note("using $file");
|
||||
$config = App::ClusterSSH::Config->new();
|
||||
%expected = %default_config;
|
||||
trap {
|
||||
$config = $config->parse_config_file( $file, );
|
||||
};
|
||||
is( $trap->leaveby, 'die', 'died ok' );
|
||||
isa_ok( $trap->die, 'App::ClusterSSH::Exception::Config' );
|
||||
isa_ok( $config, "App::ClusterSSH::Config" );
|
||||
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
||||
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
||||
is_deeply( $config, \%expected, 'amended config is correct' );
|
||||
|
||||
done_testing();
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
comms=telnet
|
||||
method=telnet
|
||||
telnet=/usr/bin/telnet
|
||||
screen_reserve_top = 100
|
||||
screen_reserve_bottom = 160
|
||||
|
||||
screen_reserve_left = 100
|
||||
|
||||
screen_reserve_right = 100
|
||||
|
||||
|
|
2
t/15config.t.file2
Normal file
2
t/15config.t.file2
Normal file
|
@ -0,0 +1,2 @@
|
|||
missing=what
|
||||
rubbish=here
|
Loading…
Add table
Reference in a new issue