1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/bin/perl
# $Id$
use strict;
use Test::More tests => 35;
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");
}
foreach my $path (qw(test test2)) {
ok(my $dconf = MDV::Distribconf->new($path), "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 $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(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: */
}
{
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: */
}
{
ok(my $dconf = MDV::Distribconf->new('not_exists', 1), "Can get new MDV::Distribconf");
$dconf->settree({
mediadir => 'mediadir',
infodir => 'infodir',
});
ok($dconf->getpath(undef, 'media_info') =~ m!^/*infodir/?$!, "Can get media_info path"); # vim color: */
}
|