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

SF.net SVN: ledger-smb:[2923] trunk/t/40-dbsetup.t



Revision: 2923
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2923&view=rev
Author:   einhverfr
Date:     2010-02-28 06:38:39 +0000 (Sun, 28 Feb 2010)

Log Message:
-----------
Added db setup tests

Modified Paths:
--------------
    trunk/t/40-dbsetup.t

Modified: trunk/t/40-dbsetup.t
===================================================================
--- trunk/t/40-dbsetup.t	2010-02-28 06:04:26 UTC (rev 2922)
+++ trunk/t/40-dbsetup.t	2010-02-28 06:38:39 UTC (rev 2923)
@@ -18,7 +18,7 @@
 }
 
 if ($run_tests){
-	plan tests => 2;
+	plan tests => 5;
 	$ENV{PGDATABASE} = $ENV{LSMB_NEW_DB};
 }
 else {
@@ -27,5 +27,61 @@
 
 # Manual tests
 open (CREATEDB, '-|', 'createdb');
-ok_cmp(<CREATEDB>, 'eq', "CREATE DATABASE\n") || BAIL_OUT('Database could not be created!');
+
+cmp_ok(<CREATEDB>, 'eq', "CREATE DATABASE\n", 'Database Created') 
+|| BAIL_OUT('Database could not be created!');
+
 close(CREATEDB);
+
+my @contrib_scripts = qw(pg_trgm tsearch2 tablefunc);
+
+for my $contrib (@contrib_scripts){
+    open (PSQL, '-|', "psql -f $ENV{PG_CONTRIB_DIR}/$contrib.sql");
+    my $test = 0;
+    while (my $line = <PSQL>){
+        chomp($line);
+        if ($line eq 'COMMIT'){
+            $test = 1;
+        }
+    }
+    if ($contrib eq 'tablefunc'){
+        $test = '1';
+    }
+    cmp_ok($test, 'eq', '1', "$contrib loaded and committed");
+    close(PSQL);
+}
+
+
+open (PSQL, '-|', "psql -f sql/Pg-database.sql");
+my $test = 0;
+while (my $line = <PSQL>){
+    chomp($line);
+    if ($line eq 'COMMIT'){
+        $test = 1;
+    }
+    if ($line =~ /error/i){
+        $test = 0;
+    }
+}
+cmp_ok($test, 'eq', '1', "DB Schema loaded and committed");
+close(PSQL);
+
+open (LOADORDER, '<', 'sql/modules/LOADORDER');
+for my $mod (<LOADORDER>){
+    chomp($mod);
+    $mod =~ s/#.*//;
+    $mod =~ s/^\s*//;
+    $mod =~ s/\s*$//;
+    next if $mod eq '';
+
+    open (PSQL, '-|', "psql -f sql/modules/$mod")&& pass("$mod loaded and committed");
+    my $test = 0;
+    while (my $line = <PSQL>){
+        chomp($line);
+        if ($line eq 'COMMIT'){
+            $test = 1;
+        }
+    }
+    close(PSQL);
+}
+close (LOADORDER)


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