[vhffs-dev] [803] Renaming Vhffs::Service::Postgres to Vhffs::Service::Pgsql (part two)

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 803
Author:   gradator
Date:     2007-08-29 23:30:27 +0000 (Wed, 29 Aug 2007)

Log Message:
-----------
Renaming Vhffs::Service::Postgres to Vhffs::Service::Pgsql (part two)

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Makefile.am
    trunk/vhffs-tests/src/Makefile.am

Added Paths:
-----------
    trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm
    trunk/vhffs-tests/src/Services/Pgsql.pl

Removed Paths:
-------------
    trunk/vhffs-api/src/Vhffs/Services/Postgres.pm
    trunk/vhffs-tests/src/Services/Postgres.pl


Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am	2007-08-29 23:28:24 UTC (rev 802)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am	2007-08-29 23:30:27 UTC (rev 803)
@@ -61,7 +61,7 @@
 	Services/MailUser.pm \
 	Services/MailGroup.pm \
 	Services/Mysql.pm \
-	Services/Postgres.pm \
+	Services/Pgsql.pm \
 	Services/Repository.pm \
 	Services/Svn.pm
 

Copied: trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm (from rev 802, trunk/vhffs-api/src/Vhffs/Services/Postgres.pm)
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm	                        (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm	2007-08-29 23:30:27 UTC (rev 803)
@@ -0,0 +1,317 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+# This file is a part of VHFFS4 platofmrm
+
+=pod
+
+=head1 NAME
+
+Vhffs::Services::Pgsql - Handle PostgreSQL databases in VHFFS.
+
+=head1 SYNOPSIS
+
+TODO
+
+=head1 METHODS
+
+=cut
+
+package Vhffs::Services::Pgsql;
+
+use base qw(Vhffs::Object);
+use strict;
+use DBI;
+
+=pod
+
+=head2 check_dbname
+
+    die('Bad DB name') unless(Vhffs::Services::Pgsql::check_dbname($dbname));
+
+Indicates wether a DB name is valid or not (3 to 32 alphanumeric chars, underscore
+allowed except at begining and end).
+
+=cut
+
+sub check_dbname($) {
+    my $dbname = shift;
+    return ( $dbname =~ /^[a-z0-9][a-z0-9\_]{1,30}[a-z0-9]$/ );
+}
+
+=pod
+
+=head2 check_dbuser
+
+    die('Bad DB username') unless(Vhffs::Services::Pgsql::check_dbuser($user));
+
+Indicates wether a DB user name is valid or not (3 to 32 lowercase alphanumeric chars, underscore
+allowed except at begining and end).
+
+=cut
+
+sub check_dbuser($) {
+    return check_dbname($_[0]);
+}
+
+
+=pod
+
+=head2 check_dbuser
+
+    die('Bad DB pass') unless(Vhffs::Services::Pgsql::check_dbpass($pass));
+
+Indicates wether a DB password is valid or not (at least one alphanumeric
+char).
+
+=cut
+    
+
+sub check_dbpass($) {
+    my $dbpass = shift;
+    return ( $dbpass =~ /^[a-zA-Z0-9]+$/);
+}
+
+sub delete
+{
+    my $self = shift;
+
+    my $query = "DELETE FROM vhffs_pgsql WHERE object_id='".$self->{'object_id'}."'";
+    my $request = $self->{'db'}->prepare($query);
+    $request->execute or return -1;
+
+    return -2 if( $self->SUPER::delete < 0 );
+    return 1;
+}
+
+=pod
+
+=head2 create
+
+    my $psql = Vhffs::Services::Pgsql::create($main, $dbname, $dbuser, $dbpass, $description, $user, $group);
+    die("Unable to create Postgre Service\n") unless(defined $psql);
+
+Create a new Postgres services and return the corresponding fully functional object.
+
+=cut
+
+sub create {
+    my ($main, $dbname, $dbuser, $dbpass, $description, $user, $group) = @_;
+    return undef unless(defined($user) && defined($group));
+    return undef unless(check_dbname($dbname) && check_dbpass($dbpass) && check_dbuser($dbuser));
+
+    my $pg;
+    my $dbh = $main->get_db_object();
+    local $dbh->{RaiseError} = 1;
+    local $dbh->{PrintError} = 0;
+    $dbh->begin_work;
+
+    eval {
+
+        my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_PGSQL);
+        die('Unable to create parent object') unless defined ($parent);
+
+        my $sql = 'INSERT INTO vhffs_pgsql(dbname, dbuser, dbpass, object_id) VALUES(?, ?, ?, ?)';
+        my $sth = $dbh->prepare($sql);
+        $sth->execute($dbname, $dbuser, $dbpass, $parent->get_oid);
+
+        $dbh->commit;
+        $pg = get_by_dbname($main, $dbname);
+    };
+
+    if($@) {
+        warn "Unable to create PostgreSQL database $dbname: $@\n";
+        $dbh->rollback;
+    }
+
+    return $pg;
+
+}
+
+sub commit
+{
+	my $self = shift;	
+
+    my $sql = 'UPDATE vhffs_pgsql SET dbuser = ?, dbpass = ? WHERE pgsql_id = ?';
+	my $sth = $self->get_db_object()->prepare( $sql );
+	$sth->execute($self->{dbuser}, $self->{dbpass}, $self->{pgsql_id});
+
+
+	$self->SUPER::commit;
+}
+
+sub get_dbusername
+{
+	my $self = shift;
+	return $self->{'dbuser'};
+}
+
+sub get_dbname
+{
+	my $self = shift;
+	return $self->{'dbname'};
+}
+
+sub get_title
+{
+	my $self = shift;
+	return $self->{'dbname'};
+}
+
+sub get_type
+{
+	return 'postgresql';
+}
+
+sub get_label {
+	my $self = shift;
+	return $self->{dbname};
+}
+
+sub get_dbpassword
+{
+	my $self = shift;
+	return $self->{'dbpass'};
+}
+
+sub set_dbusername
+{
+	my ($self , $value) = @_;	
+
+	return 1 if( $value eq $self->{'dbuser'});
+
+    return -1 if(! check_dbuser($value));
+
+	$self->{'dbuser'} = $value;
+	return 1;
+}
+
+sub set_dbpassword
+{
+	my $self = shift;
+	my $value = shift;
+	return -1 if( ! ( $value =~ /^[a-zA-Z0-9]+$/ ) );
+	$self->{'dbpass'} = $value;
+	return 1;
+}
+
+sub blank_password
+{   
+    my $self = shift;
+    
+    my $request = $self->{'db'}->prepare("UPDATE vhffs_pgsql SET dbpass='blanked' WHERE dbname='".$self->get_dbname."'") or return -1;
+    $request->execute();
+    return 1;
+}
+
+sub _new {
+    my ($class, $main, $pgsql_id, $owner_gid, $dbname, $dbuser, $dbpass, $oid, $owner_uid, $date_creation, $state, $description) = @_;
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_PGSQL);
+    return undef unless(defined $self);
+
+    $self->{pgsql_id} = $pgsql_id;
+    $self->{dbname} = $dbname;
+    $self->{dbuser} = $dbuser;
+    $self->{dbpass} = $dbpass;
+    return $self;
+}
+
+=pod
+
+=head2 get_by_dbname
+
+    my $pg = Vhffs::Services::Pgsql::get_by_dbname($main, $dbname);
+    die("No database with this name") unless(defined $pg);
+
+Fetches the pg database whose name is C<$dbname>.
+
+=cut
+
+sub get_by_dbname($$) {
+    my ($vhffs, $dbname) = @_;
+
+    my $sql = q{SELECT m.pgsql_id, o.owner_gid, m.dbname, m.dbuser, m.dbpass, o.object_id, o.owner_uid, o.date_creation, o.state, o.description FROM vhffs_pgsql m INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE m.dbname = ?};
+    my $dbh = $vhffs->get_db_object();
+    my @params;
+    return undef unless(@params = $dbh->selectrow_array($sql, undef, $dbname));
+
+    return _new Vhffs::Services::Pgsql($vhffs, @params);
+
+}
+
+=head2 fill_object
+
+See C<Vhffs::Object::fill_object>.
+
+=cut
+sub fill_object {
+    my ($class, $obj) = @_;
+    my $sql = q{SELECT pgsql_id, dbname, dbuser, dbpass FROM vhffs_pgsql
+        WHERE object_id = ?};
+    return $class->SUPER::_fill_object($obj, $sql);
+}
+
+sub getall
+{
+    my ($vhffs, $state, $name, $group) = @_;
+
+    my $postgres = [];
+    my @params;
+
+    my $sql = 'SELECT p.pgsql_id, o.owner_gid, p.dbname, p.dbuser, p.dbpass, o.object_id, o.owner_uid, o.date_creation, o.state, o.description FROM vhffs_pgsql p, vhffs_object o WHERE p.object_id = o.object_id';
+
+    if(defined $state) {
+        $sql .= ' AND o.state = ?';
+        push(@params, $state);
+    }
+    if(defined $name) {
+        $sql .= ' AND p.dbname LIKE ?';
+        push(@params, '%'.$name.'%');
+    }
+    if(defined $group) {
+        $sql .= ' AND o.owner_gid = ?';
+        push(@params, $group->get_gid);
+    }
+
+    my $dbh = $vhffs->get_db_object();
+    my $sth = $dbh->prepare($sql);
+
+    return undef unless($sth->execute(@params));
+
+    while(my $row = $sth->fetchrow_arrayref()) {
+        push(@$postgres, _new Vhffs::Services::Pgsql($vhffs, @$row));
+    }
+
+    return $postgres;
+}
+
+1;

Deleted: trunk/vhffs-api/src/Vhffs/Services/Postgres.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Postgres.pm	2007-08-29 23:28:24 UTC (rev 802)
+++ trunk/vhffs-api/src/Vhffs/Services/Postgres.pm	2007-08-29 23:30:27 UTC (rev 803)
@@ -1,317 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-
-# This file is a part of VHFFS4 platofmrm
-
-=pod
-
-=head1 NAME
-
-Vhffs::Services::Pgsql - Handle PostgreSQL databases in VHFFS.
-
-=head1 SYNOPSIS
-
-TODO
-
-=head1 METHODS
-
-=cut
-
-package Vhffs::Services::Pgsql;
-
-use base qw(Vhffs::Object);
-use strict;
-use DBI;
-
-=pod
-
-=head2 check_dbname
-
-    die('Bad DB name') unless(Vhffs::Services::Pgsql::check_dbname($dbname));
-
-Indicates wether a DB name is valid or not (3 to 32 alphanumeric chars, underscore
-allowed except at begining and end).
-
-=cut
-
-sub check_dbname($) {
-    my $dbname = shift;
-    return ( $dbname =~ /^[a-z0-9][a-z0-9\_]{1,30}[a-z0-9]$/ );
-}
-
-=pod
-
-=head2 check_dbuser
-
-    die('Bad DB username') unless(Vhffs::Services::Pgsql::check_dbuser($user));
-
-Indicates wether a DB user name is valid or not (3 to 32 lowercase alphanumeric chars, underscore
-allowed except at begining and end).
-
-=cut
-
-sub check_dbuser($) {
-    return check_dbname($_[0]);
-}
-
-
-=pod
-
-=head2 check_dbuser
-
-    die('Bad DB pass') unless(Vhffs::Services::Pgsql::check_dbpass($pass));
-
-Indicates wether a DB password is valid or not (at least one alphanumeric
-char).
-
-=cut
-    
-
-sub check_dbpass($) {
-    my $dbpass = shift;
-    return ( $dbpass =~ /^[a-zA-Z0-9]+$/);
-}
-
-sub delete
-{
-    my $self = shift;
-
-    my $query = "DELETE FROM vhffs_pgsql WHERE object_id='".$self->{'object_id'}."'";
-    my $request = $self->{'db'}->prepare($query);
-    $request->execute or return -1;
-
-    return -2 if( $self->SUPER::delete < 0 );
-    return 1;
-}
-
-=pod
-
-=head2 create
-
-    my $psql = Vhffs::Services::Pgsql::create($main, $dbname, $dbuser, $dbpass, $description, $user, $group);
-    die("Unable to create Postgre Service\n") unless(defined $psql);
-
-Create a new Postgres services and return the corresponding fully functional object.
-
-=cut
-
-sub create {
-    my ($main, $dbname, $dbuser, $dbpass, $description, $user, $group) = @_;
-    return undef unless(defined($user) && defined($group));
-    return undef unless(check_dbname($dbname) && check_dbpass($dbpass) && check_dbuser($dbuser));
-
-    my $pg;
-    my $dbh = $main->get_db_object();
-    local $dbh->{RaiseError} = 1;
-    local $dbh->{PrintError} = 0;
-    $dbh->begin_work;
-
-    eval {
-
-        my $parent = Vhffs::Object::create($main, $user->get_uid, $group->get_gid, $description, undef, Vhffs::Constants::TYPE_PGSQL);
-        die('Unable to create parent object') unless defined ($parent);
-
-        my $sql = 'INSERT INTO vhffs_pgsql(dbname, dbuser, dbpass, object_id) VALUES(?, ?, ?, ?)';
-        my $sth = $dbh->prepare($sql);
-        $sth->execute($dbname, $dbuser, $dbpass, $parent->get_oid);
-
-        $dbh->commit;
-        $pg = get_by_dbname($main, $dbname);
-    };
-
-    if($@) {
-        warn "Unable to create PostgreSQL database $dbname: $@\n";
-        $dbh->rollback;
-    }
-
-    return $pg;
-
-}
-
-sub commit
-{
-	my $self = shift;	
-
-    my $sql = 'UPDATE vhffs_pgsql SET dbuser = ?, dbpass = ? WHERE pgsql_id = ?';
-	my $sth = $self->get_db_object()->prepare( $sql );
-	$sth->execute($self->{dbuser}, $self->{dbpass}, $self->{pgsql_id});
-
-
-	$self->SUPER::commit;
-}
-
-sub get_dbusername
-{
-	my $self = shift;
-	return $self->{'dbuser'};
-}
-
-sub get_dbname
-{
-	my $self = shift;
-	return $self->{'dbname'};
-}
-
-sub get_title
-{
-	my $self = shift;
-	return $self->{'dbname'};
-}
-
-sub get_type
-{
-	return 'postgresql';
-}
-
-sub get_label {
-	my $self = shift;
-	return $self->{dbname};
-}
-
-sub get_dbpassword
-{
-	my $self = shift;
-	return $self->{'dbpass'};
-}
-
-sub set_dbusername
-{
-	my ($self , $value) = @_;	
-
-	return 1 if( $value eq $self->{'dbuser'});
-
-    return -1 if(! check_dbuser($value));
-
-	$self->{'dbuser'} = $value;
-	return 1;
-}
-
-sub set_dbpassword
-{
-	my $self = shift;
-	my $value = shift;
-	return -1 if( ! ( $value =~ /^[a-zA-Z0-9]+$/ ) );
-	$self->{'dbpass'} = $value;
-	return 1;
-}
-
-sub blank_password
-{   
-    my $self = shift;
-    
-    my $request = $self->{'db'}->prepare("UPDATE vhffs_pgsql SET dbpass='blanked' WHERE dbname='".$self->get_dbname."'") or return -1;
-    $request->execute();
-    return 1;
-}
-
-sub _new {
-    my ($class, $main, $pgsql_id, $owner_gid, $dbname, $dbuser, $dbpass, $oid, $owner_uid, $date_creation, $state, $description) = @_;
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_PGSQL);
-    return undef unless(defined $self);
-
-    $self->{pgsql_id} = $pgsql_id;
-    $self->{dbname} = $dbname;
-    $self->{dbuser} = $dbuser;
-    $self->{dbpass} = $dbpass;
-    return $self;
-}
-
-=pod
-
-=head2 get_by_dbname
-
-    my $pg = Vhffs::Services::Pgsql::get_by_dbname($main, $dbname);
-    die("No database with this name") unless(defined $pg);
-
-Fetches the pg database whose name is C<$dbname>.
-
-=cut
-
-sub get_by_dbname($$) {
-    my ($vhffs, $dbname) = @_;
-
-    my $sql = q{SELECT m.pgsql_id, o.owner_gid, m.dbname, m.dbuser, m.dbpass, o.object_id, o.owner_uid, o.date_creation, o.state, o.description FROM vhffs_pgsql m INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE m.dbname = ?};
-    my $dbh = $vhffs->get_db_object();
-    my @params;
-    return undef unless(@params = $dbh->selectrow_array($sql, undef, $dbname));
-
-    return _new Vhffs::Services::Pgsql($vhffs, @params);
-
-}
-
-=head2 fill_object
-
-See C<Vhffs::Object::fill_object>.
-
-=cut
-sub fill_object {
-    my ($class, $obj) = @_;
-    my $sql = q{SELECT pgsql_id, dbname, dbuser, dbpass FROM vhffs_pgsql
-        WHERE object_id = ?};
-    return $class->SUPER::_fill_object($obj, $sql);
-}
-
-sub getall
-{
-    my ($vhffs, $state, $name, $group) = @_;
-
-    my $postgres = [];
-    my @params;
-
-    my $sql = 'SELECT p.pgsql_id, o.owner_gid, p.dbname, p.dbuser, p.dbpass, o.object_id, o.owner_uid, o.date_creation, o.state, o.description FROM vhffs_pgsql p, vhffs_object o WHERE p.object_id = o.object_id';
-
-    if(defined $state) {
-        $sql .= ' AND o.state = ?';
-        push(@params, $state);
-    }
-    if(defined $name) {
-        $sql .= ' AND p.dbname LIKE ?';
-        push(@params, '%'.$name.'%');
-    }
-    if(defined $group) {
-        $sql .= ' AND o.owner_gid = ?';
-        push(@params, $group->get_gid);
-    }
-
-    my $dbh = $vhffs->get_db_object();
-    my $sth = $dbh->prepare($sql);
-
-    return undef unless($sth->execute(@params));
-
-    while(my $row = $sth->fetchrow_arrayref()) {
-        push(@$postgres, _new Vhffs::Services::Pgsql($vhffs, @$row));
-    }
-
-    return $postgres;
-}
-
-1;

Modified: trunk/vhffs-tests/src/Makefile.am
===================================================================
--- trunk/vhffs-tests/src/Makefile.am	2007-08-29 23:28:24 UTC (rev 802)
+++ trunk/vhffs-tests/src/Makefile.am	2007-08-29 23:30:27 UTC (rev 803)
@@ -1,5 +1,5 @@
 TESTS_ENVIRONMENT = @PERL@ -I . -I ../../vhffs-api/src/
 TESTS = Object.pl Group.pl User.pl Stats.pl Services/Svn.pl \
 	Services/Cvs.pl Services/Web.pl Services/DNS.pl Services/Mail.pl \
-	Services/Mailing.pl Services/Mysql.pl Services/Postgres.pl \
+	Services/Mailing.pl Services/Mysql.pl Services/Pgsql.pl \
 	Functions.pl Services/Repository.pl

Copied: trunk/vhffs-tests/src/Services/Pgsql.pl (from rev 802, trunk/vhffs-tests/src/Services/Postgres.pl)
===================================================================
--- trunk/vhffs-tests/src/Services/Pgsql.pl	                        (rev 0)
+++ trunk/vhffs-tests/src/Services/Pgsql.pl	2007-08-29 23:30:27 UTC (rev 803)
@@ -0,0 +1,40 @@
+use strict;
+use Vhffs::Tests::Main;
+use Vhffs::Tests::Utils;
+use Vhffs::Constants;
+use Vhffs::User;
+use Vhffs::Services::Pgsql;
+use Test::More 'no_plan';
+
+my $main = init Vhffs::Tests::Main;
+isa_ok($main, 'Vhffs::Tests::Main', '$main');
+
+Vhffs::Tests::Utils::init_db($main->get_db_object);
+
+my $user1 = Vhffs::User::create($main, 'test1', 'abcdef', 0, 'test1@xxxxxxxx');
+isa_ok($user1, 'Vhffs::User', '$user1');
+
+my $group1 = Vhffs::Group::create($main, 'pggroup1', $user1->get_uid, undef, 'Test group for postgres');
+isa_ok($group1, 'Vhffs::Group', '$group1');
+my $group2 = Vhffs::Group::create($main, 'pggroup2', $user1->get_uid, undef, 'Test group for postgres');
+isa_ok($group2, 'Vhffs::Group', '$group1');
+
+my $postgres1 = Vhffs::Services::Pgsql::create($main, 'postgres1', 'pgu1', 'plop', 'Test postgres DB 1', $user1, $group1);
+isa_ok($postgres1, 'Vhffs::Services::Pgsql', '$postgres1');
+cmp_ok($postgres1->get_dbname, 'eq', 'postgres1', 'dbname is the one defined while creating object');
+cmp_ok($postgres1->get_dbusername, 'eq', 'pgu1', 'dbuser is the one defined while creating object');
+cmp_ok($postgres1->get_owner_uid, '==', $user1->get_uid, 'uid matches');
+cmp_ok($postgres1->get_owner_gid, '==', $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::Pgsql::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::Pgsql::getall($main)};
+cmp_ok(scalar(@postgreses), '==', 1, 'Total : 1 Postgres Service');
+is_deeply($postgreses[0], $postgres1, 'getall return correct Postgres objects');
+
+cmp_ok(@{Vhffs::Services::Pgsql::getall($main, Vhffs::Constants::ACTIVATED)}, '==', 0, 'No ACTIVATED Postgres DB');
+

Deleted: trunk/vhffs-tests/src/Services/Postgres.pl
===================================================================
--- trunk/vhffs-tests/src/Services/Postgres.pl	2007-08-29 23:28:24 UTC (rev 802)
+++ trunk/vhffs-tests/src/Services/Postgres.pl	2007-08-29 23:30:27 UTC (rev 803)
@@ -1,40 +0,0 @@
-use strict;
-use Vhffs::Tests::Main;
-use Vhffs::Tests::Utils;
-use Vhffs::Constants;
-use Vhffs::User;
-use Vhffs::Services::Pgsql;
-use Test::More 'no_plan';
-
-my $main = init Vhffs::Tests::Main;
-isa_ok($main, 'Vhffs::Tests::Main', '$main');
-
-Vhffs::Tests::Utils::init_db($main->get_db_object);
-
-my $user1 = Vhffs::User::create($main, 'test1', 'abcdef', 0, 'test1@xxxxxxxx');
-isa_ok($user1, 'Vhffs::User', '$user1');
-
-my $group1 = Vhffs::Group::create($main, 'pggroup1', $user1->get_uid, undef, 'Test group for postgres');
-isa_ok($group1, 'Vhffs::Group', '$group1');
-my $group2 = Vhffs::Group::create($main, 'pggroup2', $user1->get_uid, undef, 'Test group for postgres');
-isa_ok($group2, 'Vhffs::Group', '$group1');
-
-my $postgres1 = Vhffs::Services::Pgsql::create($main, 'postgres1', 'pgu1', 'plop', 'Test postgres DB 1', $user1, $group1);
-isa_ok($postgres1, 'Vhffs::Services::Pgsql', '$postgres1');
-cmp_ok($postgres1->get_dbname, 'eq', 'postgres1', 'dbname is the one defined while creating object');
-cmp_ok($postgres1->get_dbusername, 'eq', 'pgu1', 'dbuser is the one defined while creating object');
-cmp_ok($postgres1->get_owner_uid, '==', $user1->get_uid, 'uid matches');
-cmp_ok($postgres1->get_owner_gid, '==', $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::Pgsql::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::Pgsql::getall($main)};
-cmp_ok(scalar(@postgreses), '==', 1, 'Total : 1 Postgres Service');
-is_deeply($postgreses[0], $postgres1, 'getall return correct Postgres objects');
-
-cmp_ok(@{Vhffs::Services::Pgsql::getall($main, Vhffs::Constants::ACTIVATED)}, '==', 0, 'No ACTIVATED Postgres DB');
-


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/