Changes/author for a1e1a51
[dbsrgits/DBIx-Class.git] / t / 105view_deps.t
index 66e409d..d056e9d 100644 (file)
@@ -5,14 +5,20 @@ use warnings;
 
 use Test::More;
 use Test::Exception;
+use Test::Warn;
 use lib qw(t/lib);
 use ViewDeps;
 use ViewDepsBad;
 
 BEGIN {
-    use_ok('DBIx::Class::ResultSource::View');
+    require DBIx::Class;
+    plan skip_all => 'Test needs ' .
+        DBIx::Class::Optional::Dependencies->req_missing_for('deploy')
+      unless DBIx::Class::Optional::Dependencies->req_ok_for('deploy');
 }
 
+use_ok('DBIx::Class::ResultSource::View');
+
 #################### SANITY
 
 my $view = DBIx::Class::ResultSource::View->new;
@@ -65,7 +71,9 @@ ok( $schema2, 'Connected to ViewDepsBad schema OK' );
 
 #################### DEPLOY2
 
-$schema2->deploy( { add_drop_table => 1 } );
+warnings_exist { $schema2->deploy( { add_drop_table => 1 } ); }
+[qr/no such table: main.aba_name_artists/],
+    "Deploying the bad schema produces a warning: aba_name_artists was not created.";
 
 #################### DOES ORDERING WORK 2?
 
@@ -97,7 +105,13 @@ dies_ok(
     sub {
         $schema2->resultset('AbaNameArtistsAnd2010CDsWithManyTracks')->next;
     },
-    "Query on AbaNameArtistsAnd2010CDsWithManyTracks fails, because of incorrect deploy_depends_on in AbaNameArtists"
+    "Query on AbaNameArtistsAnd2010CDsWithManyTracks dies, because of incorrect deploy_depends_on in AbaNameArtists"
 );
 
+throws_ok {
+    $schema2->resultset('AbaNameArtistsAnd2010CDsWithManyTracks')->next;
+}
+qr/no such table: aba_name_artists_and_2010_cds_with_many_tracks/,
+    "Query on AbaNameArtistsAnd2010CDsWithManyTracks throws, because the table does not exist";
+
 done_testing;