[vhffs-dev] [530] Added tests to check right transactions handling in objects' creations. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 530
Author: beuss
Date: 2007-03-25 17:28:38 +0000 (Sun, 25 Mar 2007)
Log Message:
-----------
Added tests to check right transactions handling in objects' creations.
Modified Paths:
--------------
branches/vhffs_4.1/vhffs-tests/src/Group.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Cvs.pl
branches/vhffs_4.1/vhffs-tests/src/Services/DNS.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Httpd.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Mail.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Mailing.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Mysql.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Postgres.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Repository.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Svn.pl
Modified: branches/vhffs_4.1/vhffs-tests/src/Group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Group.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Group.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -23,9 +23,12 @@
cmp_ok($group1->get_groupname, 'eq', 'testgroup1', 'Groupname matches');
# Check for groupname uniqueness constraint
-$main->get_db_object->{PrintError} = 0;
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Group::create($main, 'testgroup1', $user1->get_uid, undef, 'Test group 1')), 'Unable to create 2 groups with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'Group creation is a "all or nothing" process');
+
my $group2 = Vhffs::Group::create($main, 'testgroup1', $user1->get_uid, undef, 'Duplicate groupname');
-$main->get_db_object->{PrintError} = 1;
ok(!defined $group2, 'Unable to create a second group with the same name');
my $group1a = Vhffs::Group::get_by_gid($main, $group1->get_gid);
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Cvs.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Cvs.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Cvs.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -25,6 +25,11 @@
cmp_ok($cvs1->get_owneruid, '==', $user1->get_uid, 'uid matches');
cmp_ok($cvs1->get_ownergid, '==', $group1->get_gid, 'gid matches');
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Services::Cvs::create($main, 'cvs1', 'Test cvs repo 1', $user1, $group1)), 'Unable to create 2 repo with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'CVS service creation is a "all or nothing" process');
+
my @cvses = @{Vhffs::Services::Cvs::getall($main)};
cmp_ok(scalar(@cvses), '==', 1);
is_deeply($cvses[0], $cvs1);
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/DNS.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/DNS.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/DNS.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -24,6 +24,11 @@
cmp_ok($dns1->get_description, 'eq', 'Test DNS domain 1', 'description matches');
cmp_ok($dns1->get_domain, 'eq', 'test.com', 'Domainname matches');
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Services::DNS::create($main, 'test.com', 'Test DNS domain 1', $user1, $group1)), 'Unable to create 2 domains with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'DNS service creation is a "all or nothing" process');
+
$dns1->add_a('sample', '10.10.10.10');
my $As = $dns1->get_a_type;
cmp_ok($As->{sample}->{data}, 'eq', '10.10.10.10', 'A record IP matches');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Httpd.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Httpd.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Httpd.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -25,6 +25,12 @@
cmp_ok($web1->get_owneruid, '==', $user1->get_uid, 'uid matches');
cmp_ok($web1->get_ownergid, '==', $group1->get_gid, 'gid matches');
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Services::Httpd::create($main, 'testweb1.org', 'Test web 1', $user1, $group1)), 'Unable to create 2 webareas with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'Web service creation is a "all or nothing" process');
+
+
my @webs = @{Vhffs::Services::Httpd::getall($main)};
cmp_ok(scalar(@webs), '==', 1);
is_deeply($webs[0], $web1);
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Mail.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Mail.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Mail.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -21,6 +21,11 @@
cmp_ok($mail1->get_owneruid, '==', $user1->get_uid, 'uid matches');
cmp_ok($mail1->get_ownergid, '==', $group1->get_gid, 'gid matches');
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Services::Mail::create($main, 'test.com', 'Test mail domain 1', $user1, $group1)), 'Unable to create 2 mxdomains with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'Mail service creation is a "all or nothing" process');
+
$mail1->addforward('forward1', 'test@xxxxxxxx');
my $forwards = $mail1->get_forwards;
cmp_ok(keys(%$forwards), '==', '1', 'Forward added');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Mailing.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Mailing.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Mailing.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -25,7 +25,14 @@
my $ml1 = Vhffs::Services::Mailing::create($main, 'list1', 'test.com', 'admin@xxxxxxxx', 'Test ml 1', $user1, $group1);
isa_ok($ml1, 'Vhffs::Services::Mailing', '$ml1');
+cmp_ok($ml1->get_localpart, 'eq', 'list1', 'Local part matches');
+cmp_ok($ml1->get_domain, 'eq', 'test.com', 'Mail domain matches');
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Services::Mailing::create($main, 'list1', 'test.com', 'admin@xxxxxxxx', 'Test ml 1', $user1, $group1)), 'Unable to create 2 lists with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'Mailing list service creation is a "all or nothing" process');
+
$ml1->add_sub('toto@xxxxxxxx', Vhffs::Constants::ML_RIGHT_SUB);
cmp_ok(keys(%{$ml1->{subs}}), '==', 1, 'One subscriber registered');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Mysql.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Mysql.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Mysql.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -26,6 +26,12 @@
cmp_ok($mysql1->get_owneruid, '==', $user1->get_uid, 'uid matches');
cmp_ok($mysql1->get_ownergid, '==', $group1->get_gid, 'gid matches');
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Services::Mysql::create($main, 'mysql1', 'mysqlu1', 'plop', 'Test mysql DB 1', $user1, $group1)),
+ 'Unable to create 2 db with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'MySQL service creation is a "all or nothing" process');
+
my @mysqles = @{Vhffs::Services::Mysql::getall($main)};
cmp_ok(scalar(@mysqles), '==', 1, 'Total : 1 MySQL Service');
is_deeply($mysqles[0], $mysql1, 'getall return correct MySQL objects');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Postgres.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Postgres.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Postgres.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -26,6 +26,12 @@
cmp_ok($postgres1->get_owneruid, '==', $user1->get_uid, 'uid matches');
cmp_ok($postgres1->get_ownergid, '==', $group1->get_gid, 'gid matches');
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Services::Postgres::create($main, 'postgres1', 'pgu1', 'plop', 'Test postgres DB 1', $user1, $group1)),
+ 'Unable to create 2 db with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'PostgreSQL service creation is a "all or nothing" process');
+
my @postgreses = @{Vhffs::Services::Postgres::getall($main)};
cmp_ok(scalar(@postgreses), '==', 1, 'Total : 1 Postgres Service');
is_deeply($postgreses[0], $postgres1, 'getall return correct Postgres objects');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Repository.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Repository.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Repository.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -25,6 +25,11 @@
cmp_ok($repo1->get_owneruid, '==', $user1->get_uid, 'uid matches');
cmp_ok($repo1->get_ownergid, '==', $group1->get_gid, 'gid matches');
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Services::Repository::create($main, 'repo1', 'Test repo 1', $user1, $group1)), 'Unable to create 2 repo with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'Repository service creation is a "all or nothing" process');
+
my @repos = @{Vhffs::Services::Repository::getall($main)};
cmp_ok(scalar(@repos), '==', 1, 'Total : 1 Repository Service');
is_deeply($repos[0], $repo1, 'getall return correct Repository objects');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Svn.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Svn.pl 2007-03-25 17:27:38 UTC (rev 529)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Svn.pl 2007-03-25 17:28:38 UTC (rev 530)
@@ -25,6 +25,11 @@
cmp_ok($svn1->get_owneruid, '==', $user1->get_uid, 'uid matches');
cmp_ok($svn1->get_ownergid, '==', $group1->get_gid, 'gid matches');
+my ($max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+ok(! defined(Vhffs::Services::Svn::create($main, 'svn1', 'test svn repo 1', $user1, $group1)), 'Unable to create 2 repo with the same name');
+my ($new_max_oid) = $main->get_db_object->selectrow_array('SELECT MAX(object_id) FROM vhffs_object');
+cmp_ok($new_max_oid, '==', $max_oid, 'Svn service creation is a "all or nothing" process');
+
my @svns = @{Vhffs::Services::Svn::getall($main)};
cmp_ok(scalar(@svns), '==', 1, 'One Svn repository registered');
is_deeply($svns[0], $svn1, 'Activated Svn repository is the created one');