Author: spadkins
Date: Sun Feb 22 17:34:17 2009
New Revision: 12528
Modified:
p5ee/trunk/App-Repository/t/DBI-metadata.t
p5ee/trunk/App-Repository/t/RepositoryTestUtils.pm
Log:
fixed test to reread table list
Modified: p5ee/trunk/App-Repository/t/DBI-metadata.t
==============================================================================
--- p5ee/trunk/App-Repository/t/DBI-metadata.t (original)
+++ p5ee/trunk/App-Repository/t/DBI-metadata.t Sun Feb 22 17:34:17 2009
@@ -22,7 +22,7 @@
use App;
use App::Repository;
-use RepositoryTestUtils qw(create_table_test_person drop_table_test_person);
+use RepositoryTestUtils qw(create_table_test_person drop_table_test_person
create_table drop_table);
use strict;
if (!$App::options{dbuser}) {
@@ -62,7 +62,10 @@
my $db = $context->repository();
&drop_table_test_person($db);
&create_table_test_person($db);
+&drop_table($db,"test_country");
+&create_table($db,"test_country");
+$db->_load_rep_metadata();
###########################################################################
# METADATA TESTS
###########################################################################
@@ -74,11 +77,12 @@
$db->_load_table_metadata("test_person2");
$db->_load_table_metadata("test_person3");
$db->_load_table_metadata("test_person4");
-is_deeply($db->{table}{test_person}{primary_key}, ["person_id"], "primary_key
set from db");
-
+$db->_load_table_metadata("test_country");
+is_deeply($db->{table}{test_person}{primary_key}, ["person_id"],
"primary_key (test_person) set from db");
is_deeply($db->{table}{test_person2}{primary_key}, ["last_name",
"first_name"], "primary_key set from config (comma-sep)");
-is_deeply($db->{table}{test_person3}{primary_key}, ["person_id"], "primary_key
set from config (scalar)");
-is_deeply($db->{table}{test_person4}{primary_key}, ["person_id"], "primary_key
set from config (scalar)");
+is_deeply($db->{table}{test_person3}{primary_key}, ["person_id"],
"primary_key set from config (scalar)");
+is_deeply($db->{table}{test_person4}{primary_key}, ["person_id"],
"primary_key set from config (scalar)");
+is_deeply($db->{table}{test_country}{primary_key}, ["country_id"],
"primary_key (test_country) set from db");
my $tabledef = $db->get_table_def("test_person");
is($tabledef->{column}{person_id}{type}, "integer", "person_id type is
integer");
@@ -99,9 +103,8 @@
is($tabledef->{column}{chess_rating}{quoted}, 0, "chess_rating quoted is 0");
is($tabledef->{column}{modify_dttm}{quoted}, 1, "modify_dttm quoted is 1");
-#{
-# eval { $db->{dbh}->do("drop table test_person"); };
-#}
+&drop_table($db,"test_person");
+&drop_table($db,"test_country");
exit 0;
Modified: p5ee/trunk/App-Repository/t/RepositoryTestUtils.pm
==============================================================================
--- p5ee/trunk/App-Repository/t/RepositoryTestUtils.pm (original)
+++ p5ee/trunk/App-Repository/t/RepositoryTestUtils.pm Sun Feb 22 17:34:17 2009
@@ -34,7 +34,7 @@
my ($rep) = @_;
my $dbh = $rep->{dbh};
- my ($ddl);
+ my ($ddl, $rc);
my $dbtype = $App::options{dbtype} || "mysql";
my $autoincrement = "";
@@ -74,7 +74,9 @@
primary key (person_id)
)$suffix
EOF
- $dbh->do($ddl);
+ print "DEBUG:\n$ddl\n" if ($App::options{debug_sql});
+ $rc = $dbh->do($ddl);
+ print "DEBUG: rc=[$rc] errstr=[$DBI::errstr]\n" if
($App::options{debug_sql});
$ddl = "create index person_ie1 on test_person (last_name, first_name)";
$dbh->do($ddl);
if ($dbtype eq "oracle") {
@@ -106,7 +108,10 @@
my $dbtype = $App::options{dbtype} || "mysql";
+ print "DEBUG:\ndrop table test_person\n" if ($App::options{debug_sql});
+ my ($rc);
eval { $dbh->do("drop table test_person"); };
+ print "DEBUG: rc=[$rc] errstr=[$DBI::errstr]\n" if
($App::options{debug_sql});
#warn $@ if ($@);
if ($dbtype eq "oracle") {
eval { $dbh->do("drop sequence test_person_seq"); };
@@ -377,7 +382,9 @@
if ($dbtype eq "oracle") {
$ddl =~ s/varchar\(/varchar2\(/ig;
}
- $dbh->do($ddl);
+ print "DEBUG:\n$ddl\n" if ($App::options{debug_sql});
+ my $rc = $dbh->do($ddl);
+ print "DEBUG: rc=[$rc] errstr=[$DBI::errstr]\n" if
($App::options{debug_sql});
my $ddls = $table_index{$table};
if ($ddls) {
@@ -419,7 +426,10 @@
my $dbtype = $App::options{dbtype} || "mysql";
- eval { $dbh->do("drop table $table"); };
+ print "DEBUG:\ndrop table $table\n" if ($App::options{debug_sql});
+ my ($rc);
+ eval { $rc = $dbh->do("drop table $table"); };
+ print "DEBUG: rc=[$rc] errstr=[$DBI::errstr]\n" if
($App::options{debug_sql});
if ($dbtype eq "oracle") {
eval { $dbh->do("drop sequence ${table}_seq"); };
}