diff options
-rw-r--r-- | lib/MDV/Distribconf/Build.pm | 1 | ||||
-rw-r--r-- | t/02distribconf.t | 19 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/MDV/Distribconf/Build.pm b/lib/MDV/Distribconf/Build.pm index bbe2a5a..c5eda27 100644 --- a/lib/MDV/Distribconf/Build.pm +++ b/lib/MDV/Distribconf/Build.pm @@ -57,6 +57,7 @@ no defined parameters. sub setvalue { my ($distrib, $media, $var, $val) = @_; + $media ||= 'media_info'; if ($var) { $var =~ /^(?:media|info)dir\z/ and do { $distrib->{$var} = $val; diff --git a/t/02distribconf.t b/t/02distribconf.t index dd8cf08..5a80a82 100644 --- a/t/02distribconf.t +++ b/t/02distribconf.t @@ -3,7 +3,24 @@ # $Id$ use strict; -use Test::More tests => 1; +use Test::More tests => 7; use_ok('MDV::Distribconf::Build'); +my $dconfb = MDV::Distribconf::Build->new(); +ok($dconfb, "can create new MDV::Distribconf::Build object"); + +$dconfb->setvalue(undef, 'version', 'cooker'); +ok($dconfb->getvalue(undef, 'version') eq 'cooker', "Can set global value"); + +$dconfb->setvalue('main'); +ok(grep { $_ eq 'main' } $dconfb->listmedia, "Can add a media"); + +$dconfb->setvalue('main', 'property', 'media main'); +ok($dconfb->getvalue('main', 'property') eq 'media main', "Can set global value"); + +$dconfb->delvalue('main', 'property'); +ok(!$dconfb->getvalue('main', 'property'), "Can delete a media value"); + +$dconfb->delvalue('main'); +ok(!grep { $_ eq 'main' } $dconfb->listmedia, "Can delete a media"); |