From 09f1a45cab829277ebf3c419a7b68e0180943e9a Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Fri, 26 Dec 2008 16:13:36 +0000 Subject: [PATCH] LEONLDAP::NG : Better tests for Lemonldap::NG::Common --- modules/lemonldap-ng-common/MANIFEST | 8 ++++---- .../lib/Lemonldap/NG/Common/Conf.pm | 4 +--- .../t/{01-Manager-Conf.t => 01-Common-Conf.t} | 17 ++++++++++++++++- ...anager-Conf-File.t => 02-Common-Conf-File.t} | 6 ++++-- ...-Manager-Conf-DBI.t => 03-Common-Conf-DBI.t} | 1 + ...anager-Conf-SOAP.t => 04-Common-Conf-SOAP.t} | 0 6 files changed, 26 insertions(+), 10 deletions(-) rename modules/lemonldap-ng-common/t/{01-Manager-Conf.t => 01-Common-Conf.t} (56%) rename modules/lemonldap-ng-common/t/{02-Manager-Conf-File.t => 02-Common-Conf-File.t} (95%) rename modules/lemonldap-ng-common/t/{03-Manager-Conf-DBI.t => 03-Common-Conf-DBI.t} (99%) rename modules/lemonldap-ng-common/t/{04-Manager-Conf-SOAP.t => 04-Common-Conf-SOAP.t} (100%) diff --git a/modules/lemonldap-ng-common/MANIFEST b/modules/lemonldap-ng-common/MANIFEST index 9f0fb0f12..da9b68fb3 100644 --- a/modules/lemonldap-ng-common/MANIFEST +++ b/modules/lemonldap-ng-common/MANIFEST @@ -14,10 +14,10 @@ META.yml Module meta-data (added by MakeMaker) README scripts/lmConfig_File2MySQL storage.conf -t/01-Manager-Conf.t -t/02-Manager-Conf-File.t -t/03-Manager-Conf-DBI.t -t/04-Manager-Conf-SOAP.t +t/01-Common-Conf.t +t/02-Common-Conf-File.t +t/03-Common-Conf-DBI.t +t/04-Common-Conf-SOAP.t t/10-Common.t t/99-pod.t tools/apache-session-mysql.sql diff --git a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm index c58aafd2c..211700913 100644 --- a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm +++ b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm @@ -15,8 +15,6 @@ our %_confFiles; sub new { my $class = shift; - my $args; - $args ||= {}; my $self = bless {}, $class; if ( ref( $_[0] ) ) { %$self = %{ $_[0] }; @@ -25,7 +23,7 @@ sub new { %$self = @_; } unless ( $self->{mdone} ) { - $self->_readConfFile( $self->{confFile} ); + $self->_readConfFile( $self->{confFile} ) unless ( $self->{type} ); unless ( $self->{type} ) { $msg .= "Error: configStorage: type is not defined\n"; return 0; diff --git a/modules/lemonldap-ng-common/t/01-Manager-Conf.t b/modules/lemonldap-ng-common/t/01-Common-Conf.t similarity index 56% rename from modules/lemonldap-ng-common/t/01-Manager-Conf.t rename to modules/lemonldap-ng-common/t/01-Common-Conf.t index 03cb7de10..de6763b00 100644 --- a/modules/lemonldap-ng-common/t/01-Manager-Conf.t +++ b/modules/lemonldap-ng-common/t/01-Common-Conf.t @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; -use Test::More tests => 1; +use Test::More tests => 3; BEGIN { use_ok('Lemonldap::NG::Common::Conf') } ######################### @@ -13,3 +13,18 @@ BEGIN { use_ok('Lemonldap::NG::Common::Conf') } # 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 $h; + +ok( + ( + Lemonldap::NG::Common::Conf->new( type => 'bad' ) == 0 + and $Lemonldap::NG::Common::Conf::msg =~ + /Error: Unknown package Lemonldap::NG::Common::Conf::bad$/ + ), + 'Bad module' +); + +$h = bless {}, 'Lemonldap::NG::Common::Conf'; + +ok( $h->_readConfFile('storage.conf'), 'Read storage.conf' ); + diff --git a/modules/lemonldap-ng-common/t/02-Manager-Conf-File.t b/modules/lemonldap-ng-common/t/02-Common-Conf-File.t similarity index 95% rename from modules/lemonldap-ng-common/t/02-Manager-Conf-File.t rename to modules/lemonldap-ng-common/t/02-Common-Conf-File.t index d6ef4f33b..a3d06f1fb 100644 --- a/modules/lemonldap-ng-common/t/02-Manager-Conf-File.t +++ b/modules/lemonldap-ng-common/t/02-Common-Conf-File.t @@ -14,12 +14,14 @@ BEGIN { use_ok('Lemonldap::NG::Common::Conf') } # its man page ( perldoc Test::More ) for help writing this test script. my $h; -@ARGV = ("help=groups"); + ok( $h = new Lemonldap::NG::Common::Conf( { type => 'File', dirName => ".", } - ) + ), + 'type => file', ); + diff --git a/modules/lemonldap-ng-common/t/03-Manager-Conf-DBI.t b/modules/lemonldap-ng-common/t/03-Common-Conf-DBI.t similarity index 99% rename from modules/lemonldap-ng-common/t/03-Manager-Conf-DBI.t rename to modules/lemonldap-ng-common/t/03-Common-Conf-DBI.t index 02a0bdb8a..297c88cec 100644 --- a/modules/lemonldap-ng-common/t/03-Manager-Conf-DBI.t +++ b/modules/lemonldap-ng-common/t/03-Common-Conf-DBI.t @@ -26,3 +26,4 @@ ok( ); ok( $h->can( 'dbh' ) ); + diff --git a/modules/lemonldap-ng-common/t/04-Manager-Conf-SOAP.t b/modules/lemonldap-ng-common/t/04-Common-Conf-SOAP.t similarity index 100% rename from modules/lemonldap-ng-common/t/04-Manager-Conf-SOAP.t rename to modules/lemonldap-ng-common/t/04-Common-Conf-SOAP.t