Further work on config module

This commit is contained in:
Duncan Ferguson 2011-07-11 22:07:57 +01:00
parent 5fb98fc796
commit 81a79902b6
3 changed files with 104 additions and 12 deletions

View file

@ -114,7 +114,7 @@ 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();
$config = App::ClusterSSH::Config->new();
%expected = %default_config;
my $file = "$Bin/$Script.doesntexist";
@ -129,12 +129,12 @@ is( $trap->die,
$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;
$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, );
};
@ -147,16 +147,33 @@ is_deeply( $config, \%expected, 'amended config is correct' );
$file = "$Bin/$Script.file2";
note("using $file");
$config = App::ClusterSSH::Config->new();
$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" );
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.file3";
note("using $file");
$config = App::ClusterSSH::Config->new();
%expected = %default_config;
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' );
{
local $TODO = "deal with cluster definitions in config file";
is( $trap->stderr, q{}, 'Expecting no STDERR' );
}
done_testing();

60
t/15config.t.file3 Normal file
View file

@ -0,0 +1,60 @@
# Configuration dump produced by 'cssh -u'
auto_quit=yes
clusters=duncs test fred duncs1 fred1 test1 test2 test3 test4 test5 live test dev kvm
command=
comms=ssh
console_position=
extra_cluster_file=
history_height=10
history_width=40
key_addhost=Control-Shift-plus
key_clientname=Alt-n
key_history=Alt-h
key_paste=Control-v
key_quit=Control-q
key_retilehosts=Alt-r
max_host_menu_items=30
method=ssh
mouse_paste=Button-2
rsh_args=
screen_reserve_bottom=60
screen_reserve_left=0
screen_reserve_right=0
screen_reserve_top=0
show_history=0
ssh=/usr/bin/ssh
ssh_args= -x -o ConnectTimeout=10
telnet_args=
terminal=/usr/bin/xterm
terminal_allow_send_events=-xrm '*.VT100.allowSendEvents:true'
terminal_args=
terminal_bg_style=dark
terminal_colorize=1
terminal_decoration_height=10
terminal_decoration_width=8
terminal_font=6x13
terminal_reserve_bottom=0
terminal_reserve_left=5
terminal_reserve_right=0
terminal_reserve_top=5
terminal_size=80x24
terminal_title_opt=-T
title=CSSH
unmap_on_redraw=no
use_hotkeys=yes
window_tiling=yes
window_tiling_direction=right
duncs=orion
test=macbook
fred=duncs test
duncs1=orion
test1=macbook
fred1=duncs test
test2=macbook
test3=macbook
test4=macbook
test5=macbook
live = live1 live2 live3 \
live4 live 5 live 6
test=test1 test2 test3 test4
dev=dev1 dev2 dev3 dev4