X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2Fdbixcsl_common_tests.pm;h=2e4143cefca2b3072dc50b14ebaf4710095a947c;hb=a60b5b8dba39bf151b904b4fa5b53d65117b2801;hp=99a2d137e8ac669a164602d70daab446a01151e5;hpb=79fe00812d679113a87eed3f9031470d4116e0f5;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 99a2d13..2e4143c 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -43,7 +43,7 @@ sub _monikerize { sub run_tests { my $self = shift; - plan tests => 76; + plan tests => 80; $self->create(); @@ -444,6 +444,38 @@ sub run_tests { my $obj15 = $rsobj15->find(1); isa_ok( $obj15->loader_test14, $class14 ); } + + # rescan test + SKIP: { + skip 'SQLite does not like schema changes while connected', 4 + if $self->{vendor} =~ /sqlite/i; + + my @statements_rescan = ( + qq{ + CREATE TABLE loader_test25 ( + id INTEGER NOT NULL PRIMARY KEY, + loader_test2 INTEGER NOT NULL, + FOREIGN KEY (loader_test2) REFERENCES loader_test2 (id) + ) $self->{innodb} + }, + q{ INSERT INTO loader_test25 (id,loader_test2) VALUES(123, 1) }, + q{ INSERT INTO loader_test25 (id,loader_test2) VALUES(321, 2) }, + ); + + my $dbh = $self->dbconnect(1); + $dbh->do($_) for @statements_rescan; + $dbh->disconnect; + + my @new = $conn->rescan; + is(scalar(@new), 1); + is($new[0], 'LoaderTest25'); + + my $rsobj25 = $conn->resultset('LoaderTest25'); + isa_ok($rsobj25, 'DBIx::Class::ResultSet'); + my $obj25 = $rsobj25->find(123); + isa_ok( $obj25->loader_test2, $class2); + } + } } @@ -744,7 +776,7 @@ sub create { }, q{ INSERT INTO loader_test15 (id,loader_test14) VALUES (1,123) }, - ); + ); $self->drop_tables; @@ -817,6 +849,8 @@ sub drop_tables { loader_test14 /; + my @tables_rescan = qw/ loader_test25 /; + my $drop_fk_mysql = q{ALTER TABLE loader_test10 DROP FOREIGN KEY loader_test11_fk;}; @@ -843,6 +877,9 @@ sub drop_tables { $dbh->do("DROP TABLE $_") for (@tables_implicit_rels); } } + unless($self->{vendor} =~ /sqlite/i) { + $dbh->do("DROP TABLE $_") for (@tables_rescan); + } $dbh->do("DROP TABLE $_") for (@tables); $dbh->disconnect; }