LEMONLDAP::NG : COMMIT in DBI.pm and pb in make test

environments/ppa-mbqj77/deployments/1
Xavier Guimard 17 years ago
parent 2725f06fd3
commit 5926aed0e7
  1. 2
      build/lemonldap-ng/debian/rules
  2. 28
      modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DBI.pm
  3. 5
      modules/lemonldap-ng-portal/t/02-Lemonldap-NG-Portal-SharedConf.t

@ -52,7 +52,7 @@ install: build
dh_installdirs
# Add here commands to install the package into debian/lemonldap-ng.
#$(MAKE) test
$(MAKE) test
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp PREFIX=/usr
$(MAKE) example \
EXAMPLEROOT=debian/tmp/ \

@ -14,7 +14,8 @@ BEGIN {
sub prereq {
my $self = shift;
unless ( $self->{dbiChain} ) {
$Lemonldap::NG::Common::Conf::msg = '"dbiChain" is required in DBI configuration type';
$Lemonldap::NG::Common::Conf::msg =
'"dbiChain" is required in DBI configuration type';
return 0;
}
print STDERR __PACKAGE__ . 'Warning: "dbiUser" parameter is not set'
@ -25,8 +26,7 @@ sub prereq {
sub available {
my $self = shift;
my $sth =
$self->dbh->prepare(
my $sth = $self->dbh->prepare(
"SELECT cfgNum from " . $self->{dbiTable} . " order by cfgNum" );
$sth->execute();
my @conf;
@ -38,8 +38,8 @@ sub available {
sub lastCfg {
my $self = shift;
my @row =
$self->dbh->selectrow_array( "SELECT max(cfgNum) from " . $self->{dbiTable} );
my @row = $self->dbh->selectrow_array(
"SELECT max(cfgNum) from " . $self->{dbiTable} );
return $row[0];
}
@ -55,7 +55,7 @@ sub dbh {
sub lock {
my $self = shift;
my $sth = $self->dbh->prepare_cached(q{SELECT GET_LOCK(?, 5)}, {}, 1);
my $sth = $self->dbh->prepare_cached( q{SELECT GET_LOCK(?, 5)}, {}, 1 );
$sth->execute('lmconf');
my @row = $sth->fetchrow_array;
return $row[0] || 0;
@ -63,7 +63,7 @@ sub lock {
sub isLocked {
my $self = shift;
my $sth = $self->dbh->prepare_cached(q{SELECT IS_FREE_LOCK(?)}, {}, 1);
my $sth = $self->dbh->prepare_cached( q{SELECT IS_FREE_LOCK(?)}, {}, 1 );
$sth->execute('lmconf');
my @row = $sth->fetchrow_array;
return $row[0] ? 0 : 1;
@ -71,7 +71,7 @@ sub isLocked {
sub unlock {
my $self = shift;
my $sth = $self->dbh->prepare_cached(q{SELECT RELEASE_LOCK(?)}, {}, 1);
my $sth = $self->dbh->prepare_cached( q{SELECT RELEASE_LOCK(?)}, {}, 1 );
$sth->execute('lmconf');
my @row = $sth->fetchrow_array;
return $row[0] || 0;
@ -90,18 +90,18 @@ sub store {
$self->logError;
return UNKNOWN_ERROR;
}
unless( $self->unlock ) {
unless ( $self->unlock ) {
$self->logError;
return UNKNOWN_ERROR;
}
eval { $self->dbh->do("COMMIT"); };
return $fields->{cfgNum};
}
sub load {
my ( $self, $cfgNum, $fields ) = @_;
$fields = $fields ? join( ",", @$fields ) : '*';
my $row =
$self->dbh->selectrow_hashref(
my $row = $self->dbh->selectrow_hashref(
"SELECT $fields from " . $self->{dbiTable} . " WHERE cfgNum=$cfgNum" );
unless ($row) {
$self->logError;
@ -112,12 +112,14 @@ sub load {
sub delete {
my ( $self, $cfgNum ) = @_;
$self->dbh->do( "DELETE from " . $self->{dbiTable} . " WHERE cfgNum=$cfgNum" );
$self->dbh->do(
"DELETE from " . $self->{dbiTable} . " WHERE cfgNum=$cfgNum" );
}
sub logError {
my $self = shift;
$Lemonldap::NG::Common::Conf::msg = "Database error: " . $self->dbh->errstr . "\n";
$Lemonldap::NG::Common::Conf::msg =
"Database error: " . $self->dbh->errstr . "\n";
}
1;

@ -5,7 +5,7 @@
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 3;
use Test::More tests => 1;
BEGIN { use_ok('Lemonldap::NG::Portal::SharedConf') }
#########################
@ -13,7 +13,4 @@ BEGIN { use_ok('Lemonldap::NG::Portal::SharedConf') }
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
my $p = bless {}, 'Lemonldap::NG::Portal::SharedConf';
ok( !$p->scanexpr('1 == 0') );
ok( $p->scanexpr('1 == 1') );

Loading…
Cancel
Save