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
52
|
#!/usr/bin/perl
# $Id: 01-compile.t 38877 2006-07-12 12:16:51Z nanardon $
use strict;
use warnings;
use Test::More tests => 28;
use File::Temp qw(tempdir);
use_ok('MDV::Distribconf::Build');
my $dir = tempdir();
sub END {
if (-d $dir) {
system(qw(rm -fr --), $dir);
}
}
my $mdb = MDV::Distribconf::Build->new($dir);
isa_ok($mdb, 'MDV::Distribconf::Build');
$mdb->settree();
ok($mdb->init(), "Can create a distrib");
ok(-d $mdb->getfullpath(undef, 'infodir'), 'info directory has been created');
ok($mdb->create_media('media_a'), 'can create a media');
ok($mdb->mediaexists('media_a'), 'media_a exists');
ok(-d $mdb->getfullpath('media_a', 'path'), 'media directory has been created');
ok(-d $mdb->getfullpath('media_a', 'infodir'), 'media info directory has been created');
ok($mdb->create_media('media_b'), 'can create a second media');
ok($mdb->mediaexists('media_b'), 'media_b exists');
ok($mdb->setvalue('media_a', 'srpms', 'media_b'), 'set a new value');
is($mdb->getvalue('media_a', 'srpms'), 'media_b', 'set value works');
is($mdb->getvalue('media_b', 'rpms'), 'media_a', 'set peer value works');
ok($mdb->setvalue('media_a', 'srpms', ''), 'set a new value');
is($mdb->getvalue('media_a', 'srpms'), '', 'reset value works');
is($mdb->getvalue('media_b', 'rpms'), '', 'reset peer value works');
ok($mdb->setvalue('media_a', 'srpms', 'media_c'), 'set a new value');
ok(!$mdb->mediaexists('media_c'), 'peer media does not exists');
ok($mdb->setvalue('media_c'), 'lazy media creation');
is($mdb->getvalue('media_c', 'rpms'), 'media_a', 'set peer value works');
ok($mdb->create_media('media_c'), 'can create a third media');
ok(-d $mdb->getfullpath('media_c', 'path'), 'media directory has been created');
ok(-d $mdb->getfullpath('media_c', 'infodir'), 'media info directory has been created');
ok($mdb->delvalue('media_c', 'rpms'), 'deleting a value works');
is($mdb->getvalue('media_a', 'srpms'), '', 'delete peer value works');
ok($mdb->setvalue('media_a', 'srpms', 'media_c'), 'set a new value');
ok($mdb->delvalue('media_c'), 'deleting a media works');
is($mdb->getvalue('media_a', 'srpms'), '', 'delete peer value works');
|