Bumping version to 0.07049
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_02mysql_common.t
index e850cbf..504e60c 100644 (file)
@@ -1,10 +1,12 @@
+use DBIx::Class::Schema::Loader::Optional::Dependencies
+    -skip_all_without => 'test_rdbms_mysql';
+
 use strict;
 use warnings;
 use Test::More;
 use Test::Exception;
 use Try::Tiny;
 use File::Path 'rmtree';
-use DBIx::Class::Optional::Dependencies;
 use DBIx::Class::Schema::Loader::Utils 'slurp_file';
 use DBIx::Class::Schema::Loader 'make_schema_at';
 
@@ -26,7 +28,9 @@ my $innodb = $test_innodb ? q{Engine=InnoDB} : '';
 
 my ($schema, $databases_created); # for cleanup in END for extra tests
 
-my $tester = dbixcsl_common_tests->new(
+diag $skip_rels_msg if not $test_innodb;
+
+dbixcsl_common_tests->new(
     vendor            => 'Mysql',
     auto_inc_pk       => 'INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT',
     innodb            => $innodb,
@@ -115,7 +119,6 @@ my $tester = dbixcsl_common_tests->new(
         'time'        => { data_type => 'time' },
         'year'        => { data_type => 'year' },
         'year(4)'     => { data_type => 'year' },
-        'year(2)'     => { data_type => 'year', size => 2 },
 
         # String Types
         'char'         => { data_type => 'char',      size => 1  },
@@ -202,7 +205,7 @@ my $tester = dbixcsl_common_tests->new(
         ],
         pre_drop_ddl => [ 'DROP VIEW mysql_loader_test2', ],
         drop => [ 'mysql_loader-test1', 'mysql_loader_test3', 'mysql_loader_test11', 'mysql_loader_test12' ],
-        count => 9 + 30 * 2,
+        count => 10 + 30 * 2,   # regular + multi-schema * 2
         run => sub {
             my ($monikers, $classes);
             ($schema, $monikers, $classes) = @_;
@@ -216,8 +219,13 @@ my $tester = dbixcsl_common_tests->new(
                 'view introspected successfully';
 
             # test that views are marked as such
-            isa_ok $schema->resultset($monikers->{mysql_loader_test2})->result_source, 'DBIx::Class::ResultSource::View',
-                'views have table_class set correctly';
+            my $view_source = $schema->resultset($monikers->{mysql_loader_test2})->result_source;
+            isa_ok $view_source, 'DBIx::Class::ResultSource::View',
+                'view result source';
+
+            like $view_source->view_definition,
+                qr/\A \s* select \b .* \b from \s+ `.*?` \. `mysql_loader-test1` \s* \z/imsx,
+                'view defintion';
 
             $rsrc = $schema->source('MysqlLoaderTest3');
 
@@ -337,7 +345,7 @@ EOF
                             $dbh->selectall_arrayref('SHOW DATABASES');
                         }
                         catch {
-                            skip 'no SHOW DATABASES privileges', 28;
+                            skip 'no SHOW DATABASES privileges', 30;
                         }
                     }
 
@@ -500,18 +508,7 @@ EOF
             }
         },
     },
-);
-
-if( !$dsn || !$user ) {
-    $tester->skip_tests('You need to set the DBICTEST_MYSQL_DSN, DBICTEST_MYSQL_USER, and DBICTEST_MYSQL_PASS environment variables');
-}
-elsif (!DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_mysql')) {
-    $tester->skip_tests('You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_mysql'));
-}
-else {
-    diag $skip_rels_msg if not $test_innodb;
-    $tester->run_tests();
-}
+)->run_tests;
 
 END {
     if (not $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}) {