summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/05build.t52
1 files changed, 52 insertions, 0 deletions
diff --git a/t/05build.t b/t/05build.t
new file mode 100644
index 0000000..1def21d
--- /dev/null
+++ b/t/05build.t
@@ -0,0 +1,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');