X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2Fdbixcsl_mssql_extra_tests.pm;h=bafe790b31e65025eb86d11af0445316ae94e525;hb=d073740eae0165b8e07ac95d481feb1b2be36ee0;hp=ea38461412f8f52b7b0ee04ab6e7d5c2fb6d916d;hpb=805dbe0a6a5c6ca73f3d99e5c57a18ee14248058;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/lib/dbixcsl_mssql_extra_tests.pm b/t/lib/dbixcsl_mssql_extra_tests.pm index ea38461..bafe790 100644 --- a/t/lib/dbixcsl_mssql_extra_tests.pm +++ b/t/lib/dbixcsl_mssql_extra_tests.pm @@ -1,6 +1,7 @@ package dbixcsl_mssql_extra_tests; use Test::More; +use Test::Exception; my $vendor = 'mssql'; @@ -9,6 +10,9 @@ sub vendor { $vendor = shift; } +# for cleanup in END +my $saved_dbh; + sub extra { +{ create => [ qq{ @@ -26,9 +30,22 @@ sub extra { +{ ts DATETIME DEFAULT getdate() ) }, + qq{ + CREATE TABLE ${vendor}_loader_test3 ( + id INT IDENTITY NOT NULL PRIMARY KEY + ) + }, + qq{ + CREATE VIEW ${vendor}_loader_test4 AS + SELECT * FROM ${vendor}_loader_test3 + }, + ], + drop => [ + "[${vendor}_loader_test1.dot]", + "${vendor}_loader_test2", + "${vendor}_loader_test3" ], - drop => [ "[${vendor}_loader_test1.dot]", "${vendor}_loader_test2" ], - count => 13, + count => 15, run => sub { my ($schema, $monikers, $classes) = @_; @@ -84,7 +101,35 @@ sub extra { +{ is $identity_col_info->{is_auto_increment}, 1, q{'INT IDENTITY' column has is_auto_increment => 1}; + +# Test that a bad view (where underlying table is gone) is ignored. + $saved_dbh = $schema->storage->dbh; + $saved_dbh->do("DROP TABLE ${vendor}_loader_test3"); + + my @warnings; + { + local $SIG{__WARN__} = sub { push @warnings, $_[0] }; + $schema->rescan; + } + ok ((grep /^Bad table or view '${vendor}_loader_test4'/, @warnings), + 'bad view ignored'); + + throws_ok { + $schema->resultset("${vendor_titlecased}LoaderTest4") + } qr/Can't find source/, + 'no source registered for bad view'; }, }} +# Clean up the bad view, table will be cleaned up in drops +END { + local $@; + eval { + $saved_dbh->do($_) for ( +"CREATE TABLE ${vendor}_loader_test3 (id INT IDENTITY NOT NULL PRIMARY KEY)", +"DROP VIEW ${vendor}_loader_test4" + ); + }; +} + 1;