[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3413] trunk



Revision: 3413
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3413&view=rev
Author:   einhverfr
Date:     2011-07-02 12:23:28 +0000 (Sat, 02 Jul 2011)

Log Message:
-----------
database creation script and test case fixes

Modified Paths:
--------------
    trunk/LedgerSMB/Database.pm
    trunk/README.tests
    trunk/t/40-dbsetup.t

Modified: trunk/LedgerSMB/Database.pm
===================================================================
--- trunk/LedgerSMB/Database.pm	2011-07-02 10:46:38 UTC (rev 3412)
+++ trunk/LedgerSMB/Database.pm	2011-07-02 12:23:28 UTC (rev 3413)
@@ -58,13 +58,6 @@
     if ($self->{source_dir}){
         $self->{source_dir} =~ s/\/*$/\//;
     }
-    if (isa($args, 'LedgerSMB')){
-        for (keys %$args){
-            if ($_ =~ /^_/){
-                $self->{$_} = $args->{$_};
-            }
-        }
-    }
     bless $self, $class;
     return $self;
 }
@@ -90,16 +83,16 @@
 
      for my $contrib (@contrib_scripts){
          my $rc2;
-         $rc2=system("psql -f $ENV{PG_CONTRIB_DIR}/$contrib.sql >>$temp/dblog");
+         $rc2=system("psql -f $ENV{PG_CONTRIB_DIR}/$contrib.sql 2>>$temp/dblog");
          $rc ||= $rc2
      }
-     if (!system("psql -f $self->{source_dir}sql/Pg-database.sql >> $temp/dblog"
+     if (!system("psql -f $self->{source_dir}sql/Pg-database.sql 2>>$temp/dblog"
      )){
          $rc = 1;
      }
      # TODO Add logging of errors/notices
 
-     return !$rc;
+     return $rc;
 }
 
 =item $db->load_modules($loadorder)
@@ -184,7 +177,7 @@
     close ROLES;
     close TROLES;
 
-    $self->exec_script({script => "sql/modules/$rolefile", 
+    $self->exec_script({script => "$temp/lsmb_roles.sql", 
                         log    => "$temp/dblog"});
 }
 

Modified: trunk/README.tests
===================================================================
--- trunk/README.tests	2011-07-02 10:46:38 UTC (rev 3412)
+++ trunk/README.tests	2011-07-02 12:23:28 UTC (rev 3413)
@@ -13,10 +13,10 @@
 
 LSMB_TEST_DB must be set to a defined value if databases are going to be tested.
 
-if LSMB_NEW_DB is set, test 40 (when it is complete) will create a database with
-the name from this environment variable, and subsequent database tests will run
-against that database.  If this is not set, and PGDATABASE is set, tests will 
-run on that database. If neither are set, the tests will bail out.
+if LSMB_NEW_DB is set, test 40 will create a database with the name from this 
+environment variable, and subsequent database tests will run against that 
+database.  If this is not set, and PGDATABASE is set, tests will run on that 
+database. If neither are set, the tests will bail out.
 
 Special notes on specific test cases:
 
@@ -75,7 +75,7 @@
 
 Chart of accounts loading
 -------------------------
-    LSMB_LOAD_COA name of the Chart of Accounts file (minus the extension)
-   LSMB_LOAD_GIFI name of the GIFI file (minus the extension)
+    LSMB_LOAD_COA name of the Chart of Accounts file, not including extension
+   LSMB_LOAD_GIFI name of the GIFI file, not including extension
 LSMB_COUNTRY_CODE Country code for administrator and for loading chart of 
                   accounts

Modified: trunk/t/40-dbsetup.t
===================================================================
--- trunk/t/40-dbsetup.t	2011-07-02 10:46:38 UTC (rev 3412)
+++ trunk/t/40-dbsetup.t	2011-07-02 12:23:28 UTC (rev 3413)
@@ -23,7 +23,7 @@
 }
 
 if ($run_tests){
-	plan tests => 35;
+	plan tests => 10;
 	$ENV{PGDATABASE} = $ENV{LSMB_NEW_DB};
 }
 
@@ -49,13 +49,13 @@
     close (DBLOCK);
 }
 
-ok($db->process_roles('Roles.sql'), 'Roles processed');
+is($db->process_roles('Roles.sql'), 0, 'Roles processed');
 
 #Changed the COA and GIFI loading to use this, and move admin user to 
 #Database.pm --CT
 
 SKIP: {
-     skip 'No admin info', 4
+     skip 'No admin info', 5
            if (!defined $ENV{LSMB_ADMIN_USERNAME} 
                 or !defined $ENV{LSMB_ADMIN_PASSWORD}
                 or !defined $ENV{LSMB_COUNTRY_CODE}
@@ -78,9 +78,8 @@
                    last_name  => $ENV{LSMB_ADMIN_LNAME},
                    country_id => $ref->{id},
                  });
-      my ($var) = $sth->fetchrow_array();
-      cmp_ok($var, '>', 0, 'User id retrieved');
-      $sth->finish;
+      my $user = LedgerSMB::DBObject::Admin->new({base => $lsmb});
+      ok($user->save);
       $sth = $dbh->prepare("SELECT admin__add_user_to_role(?, ?)");
       my $rolename = "lsmb_" . $ENV{PGDATABASE} . "__users_manage";
       ok($sth->execute($ENV{LSMB_ADMIN_USERNAME}, $rolename), 
@@ -90,18 +89,20 @@
 };
 
 SKIP: {
-     skip 'No COA specified', 2 if !defined $ENV{LSMB_LOAD_COA};
-     ok($db->exec_script('sql/coa/' 
-                         . lc($ENV{LSMB_COUNTRY_CODE}) 
-                         ."/chart/$ENV{LSMB_LOAD_COA}.sql"),
+     skip 'No COA specified', 1 if !defined $ENV{LSMB_LOAD_COA};
+     is($db->exec_script({script => 'sql/coa/' 
+                                     . lc($ENV{LSMB_COUNTRY_CODE}) 
+                                     ."/chart/$ENV{LSMB_LOAD_COA}.sql"
+                         }), 0,
         'Ran Chart of Accounts Script');
 }
 
 SKIP: {
-     skip 'No GIFI specified', 2 if !defined $ENV{LSMB_LOAD_GIFI};
-     ok($db->exec_script('sql/coa/' 
-                         . lc($ENV{LSMB_COUNTRY_CODE}) 
-                         ."/chart/$ENV{LSMB_LOAD_GIFI}.sql"),
+     skip 'No GIFI specified', 1 if !defined $ENV{LSMB_LOAD_GIFI};
+     is($db->exec_script({script => 'sql/coa/' 
+                                   . lc($ENV{LSMB_COUNTRY_CODE}) 
+                                    ."/gifi/$ENV{LSMB_LOAD_GIFI}.sql"
+                         }), 0,
         'Ran GIFI Script');
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.