Minor cleanup of ::Optional::Dependencies innards
[dbsrgits/DBIx-Class-Historic.git] / t / 105view_deps.t
index 66e409d..a2e5485 100644 (file)
@@ -5,11 +5,16 @@ use warnings;
 
 use Test::More;
 use Test::Exception;
+use Test::Warn;
 use lib qw(t/lib);
 use ViewDeps;
 use ViewDepsBad;
 
 BEGIN {
+    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');
 }
 
@@ -65,7 +70,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 +104,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;