diff options
author | Olivier Thauvin <nanardon@mandriva.org> | 2006-08-24 22:50:09 +0000 |
---|---|---|
committer | Olivier Thauvin <nanardon@mandriva.org> | 2006-08-24 22:50:09 +0000 |
commit | 50e39ef4b0a9ea513a934a572f99905260e0140d (patch) | |
tree | 2b8295c4fbfeb5572a24c2a7de2cbdd93906f451 /t | |
parent | a2acafce4b2c1b26cc9aea46d88c299dfabb3da6 (diff) | |
download | perl-MDV-Distribconf-50e39ef4b0a9ea513a934a572f99905260e0140d.tar perl-MDV-Distribconf-50e39ef4b0a9ea513a934a572f99905260e0140d.tar.gz perl-MDV-Distribconf-50e39ef4b0a9ea513a934a572f99905260e0140d.tar.bz2 perl-MDV-Distribconf-50e39ef4b0a9ea513a934a572f99905260e0140d.tar.xz perl-MDV-Distribconf-50e39ef4b0a9ea513a934a572f99905260e0140d.zip |
- fix getpath(undef, 'infodir')3.05
Diffstat (limited to 't')
-rw-r--r-- | t/01distribconf.t | 93 |
1 files changed, 75 insertions, 18 deletions
diff --git a/t/01distribconf.t b/t/01distribconf.t index fb7f3c4..b494c6d 100644 --- a/t/01distribconf.t +++ b/t/01distribconf.t @@ -3,7 +3,16 @@ # $Id$ use strict; -use Test::More tests => 35; +use Test::More; + +my %testdpath = ( + 'testdata/test' => undef, + 'testdata/test2' => undef, + 'testdata/test3' => undef, + 'http://server/path/' => 'testdata/test/media/media_info/media.cfg', +); + +plan tests => 14 + 21 * scalar(keys %testdpath); use_ok('MDV::Distribconf'); @@ -12,34 +21,51 @@ ok(my $dconf = MDV::Distribconf->new('/dev/null'), "Can get new MDV::Distribconf ok(!$dconf->load(), "loading wrong distrib give error"); } -foreach my $path (qw(test test2)) { +foreach my $path (keys %testdpath) { ok(my $dconf = MDV::Distribconf->new($path), "Can get new MDV::Distribconf"); - ok($dconf->load(), "Can load conf"); + if ($testdpath{$path}) { + $dconf->settree('mandriva'); + } else { + ok($dconf->load(), "Can load conf"); + } + + is($dconf->getpath(undef, 'root'), $path, "Can get root path"); + like($dconf->getpath(undef, 'media_info'), qr!^/*media/media_info/?$!, "Can get media_info path"); # vim color: */ + like($dconf->getpath(undef, 'infodir'), qr!^/*media/media_info/?$!, "Can get infodir"); # vim color: */ + like($dconf->getpath(undef, 'mediadir'), qr!^/*media/?$!, "Can get infodir"); # vim color: */ + + if ($testdpath{$path}) { + ok($dconf->parse_mediacfg($testdpath{$path}), "can parse media.cfg"); + } ok(scalar($dconf->listmedia) == 8, "Can list all media"); - ok(grep { $_ eq 'main' } $dconf->listmedia, "list properly media"); - - ok($dconf->getvalue(undef, 'version') eq '2006.0', "Can get global value"); - ok($dconf->getvalue('main', 'version') eq '2006.0', "Can get global value via media"); - ok($dconf->getvalue('main', 'name') eq 'main', "Can get default name"); - ok($dconf->getvalue('contrib', 'name') eq 'Contrib', "Can get media name"); - - ok($dconf->getpath(undef, 'root') eq $path, "Can get root path"); - ok($dconf->getpath(undef, 'media_info') =~ m!^/*media/media_info/?$!, "Can get media_info path"); # vim color: */ - ok($dconf->getfullpath(undef, 'media_info') =~ m!^/*$path/+media/media_info/?$!, "Can get media_info fullpath"); # vim color: */ - ok($dconf->getpath('main', 'path') =~ m!^/*media/+main/?$!, "Can get media path"); # vim color: */ - ok($dconf->getfullpath('main', 'path') =~ m!^/*$path/*media/+main/?$!, "Can get media fullpath"); # vim color: */ + ok((grep { $_ eq 'main' } $dconf->listmedia), "list properly media"); + + is($dconf->getvalue(undef, 'version'), '2006.0', "Can get global value"); + is($dconf->getvalue('main', 'version'), '2006.0', "Can get global value via media"); + is($dconf->getvalue('main', 'name'), 'main', "Can get default name"); + is($dconf->getvalue('contrib', 'name'), 'Contrib', "Can get media name"); + + is($dconf->getpath(undef, 'root'), $path, "Can get root path"); + like($dconf->getpath(undef, 'media_info'), qr!^/*media/media_info/?$!, "Can get media_info path"); # vim color: */ + like($dconf->getfullpath(undef, 'media_info'), qr!^/*$path/+media/media_info/?$!, "Can get media_info fullpath"); # vim color: */ + like($dconf->getpath('main', 'path'), qr!^/*media/+main/?$!, "Can get media path"); # vim color: */ + like($dconf->getfullpath('main', 'path'), qr!^/*$path/*media/+main/?$!, "Can get media fullpath"); # vim color: */ + like($dconf->getpath('main', 'hdlist'), qr!^/*media/+media_info/+hdlist_main.cz$!, "Can get media path"); # vim color: */ + like($dconf->getfullpath('main', 'hdlist'), qr!^/*$path/*media/+media_info/+hdlist_main.cz$!, "Can get media fullpath"); # vim color: */ + like($dconf->getmediapath('main', 'hdlist'), qr!^/*media/+main/+media_info/+hdlist.cz$!, "Can get media path"); # vim color: */ + like($dconf->getfullmediapath('main', 'hdlist'), qr!^/*$path/*media/+main/+media_info/+hdlist.cz$!, "Can get media fullpath"); # vim color: */ } { ok(my $dconf = MDV::Distribconf->new('not_exists', 1), "Can get new MDV::Distribconf"); $dconf->settree(); -ok($dconf->getpath(undef, 'media_info') =~ m!^/*media/media_info/?$!, "Can get media_info path"); # vim color: */ +like($dconf->getpath(undef, 'media_info'), qr!^/*media/media_info/?$!, "Can get media_info path"); # vim color: */ } { ok(my $dconf = MDV::Distribconf->new('not_exists', 1), "Can get new MDV::Distribconf"); $dconf->settree('manDraKE'); -ok($dconf->getpath(undef, 'media_info') =~ m!^/*Mandrake/base/?$!, "Can get media_info path"); # vim color: */ +like($dconf->getpath(undef, 'media_info'), qr!^/*Mandrake/base/?$!, "Can get media_info path"); # vim color: */ } { ok(my $dconf = MDV::Distribconf->new('not_exists', 1), "Can get new MDV::Distribconf"); @@ -47,5 +73,36 @@ $dconf->settree({ mediadir => 'mediadir', infodir => 'infodir', }); -ok($dconf->getpath(undef, 'media_info') =~ m!^/*infodir/?$!, "Can get media_info path"); # vim color: */ +like($dconf->getpath(undef, 'media_info'), qr!^/*infodir/?$!, "Can get media_info path"); # vim color: */ +} + +{ + # test for %{} ${} var + my $dc = MDV::Distribconf->new('testdata/test3'); + $dc->load(); + is( + $dc->_expand(undef, '${version}'), + '2006.0', + 'expand works' + ); + is( + $dc->_expand('jpackage', '%{name}'), + 'jpackage', + 'expand works' + ); + is( + $dc->_expand('jpackage', '${version}'), + '2006.0', + 'expand works' + ); + is( + $dc->_expand(undef, '%{foo}'), + '%{foo}', + 'expand works' + ); + is( + $dc->getvalue('jpackage', 'hdlist'), + 'hdlist_jpackage.cz', + 'getvalue works' + ); } |