diff options
-rw-r--r-- | lib/MDV/Distribconf.pm | 2 | ||||
-rw-r--r-- | t/01distribconf.t | 24 | ||||
-rw-r--r-- | test/media/media_info/media.cfg | 42 |
3 files changed, 66 insertions, 2 deletions
diff --git a/lib/MDV/Distribconf.pm b/lib/MDV/Distribconf.pm index c6873a8..8d099f4 100644 --- a/lib/MDV/Distribconf.pm +++ b/lib/MDV/Distribconf.pm @@ -354,7 +354,7 @@ of media, location of index files, and paths set in the configuration. sub getpath { my ($distrib, $media, $var) = @_; - + $var ||= ""; # Avoid undef value my $val = $distrib->getvalue($media, $var); $var =~ /^(?:root|VERSION)$/ and return $val; return ($val =~ m!/! ? "" : ($var eq 'path' ? $distrib->{mediadir} : $distrib->{infodir} ) . "/") . $val; diff --git a/t/01distribconf.t b/t/01distribconf.t index b058419..8899d40 100644 --- a/t/01distribconf.t +++ b/t/01distribconf.t @@ -3,7 +3,29 @@ # $Id$ use strict; -use Test::More tests => 1; +use Test::More tests => 16; use_ok('MDV::Distribconf'); +{ +ok(my $dconf = MDV::Distribconf->new('/dev/null'), "Can get new MDV::Distribconf"); +ok(!$dconf->load(), "loading wrong distrib give error"); +} + +ok(my $dconf = MDV::Distribconf->new('test'), "Can get new MDV::Distribconf"); +ok($dconf->load(), "Can load conf"); + +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 'test', "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!^/*test/+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!^/*test/*media/+main/?$!, "Can get media fullpath"); # vim color: */ + diff --git a/test/media/media_info/media.cfg b/test/media/media_info/media.cfg new file mode 100644 index 0000000..8c8e609 --- /dev/null +++ b/test/media/media_info/media.cfg @@ -0,0 +1,42 @@ +# $Id$ + +[media_info] +version=2006.0 +branch=Cooker +arch=i586 + +[main] +hdlist=hdlist_main.cz +size=3400m + +[debug_main] +debugfor=main + +[../SRPMS/main] +hdlist=hdlist_main.src.cz +name=Main Sources +noauto=1 + +[contrib] +hdlist=hdlist_contrib.cz +name=Contrib +size=4300m + +[debug_contrib] +debugfor=contrib + +[../SRPMS/contrib] +hdlist=hdlist_contrib.src.cz +name=Contrib Sources +noauto=1 + +[jpackage] +hdlist=hdlist_jpackage.cz +name=Jpackage +size=360m +noauto=1 + +[../SRPMS/jpackage] +hdlist=hdlist_jpackage.src.cz +name=Jpackage Sources +noauto=1 |