Smarter todoification (this doesn't sound like a bad idea for CPAN in general)
[dbsrgits/DBIx-Class.git] / t / storage / replicated.t
index 6919e5f..dfd3870 100644 (file)
@@ -10,13 +10,13 @@ BEGIN {
     require DBIx::Class;
     plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_replicated')
       unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_replicated');
-}
 
+    if (DBICTest::RunMode->is_smoker) {
+      my $mver = Moose->VERSION;
+      plan skip_all => "A trial version $mver of Moose detected known to break replication - skipping test known to fail"
+        if ($mver >= 1.99 and $mver <= 1.9902);
+    }
 
-if (DBICTest::RunMode->is_smoker) {
-  my $mver = Moose->VERSION;
-  plan skip_all => "A trial version $mver of Moose detected known to break replication - skipping test known to fail"
-    if ($mver >= 1.99 and $mver <= 1.9902);
 }
 
 use Test::Moose;
@@ -31,10 +31,26 @@ note "Using Moose version $Moose::VERSION and MooseX::Types version $MooseX::Typ
 
 my $var_dir = quotemeta ( File::Spec->catdir(qw/t var/) );
 
-use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool';
-use_ok 'DBIx::Class::Storage::DBI::Replicated::Balancer';
-use_ok 'DBIx::Class::Storage::DBI::Replicated::Replicant';
-use_ok 'DBIx::Class::Storage::DBI::Replicated';
+## Add a connect_info option to test option merging.
+use DBIx::Class::Storage::DBI::Replicated;
+{
+    package DBIx::Class::Storage::DBI::Replicated;
+
+    use Moose;
+
+    __PACKAGE__->meta->make_mutable;
+
+    around connect_info => sub {
+      my ($next, $self, $info) = @_;
+      $info->[3]{master_option} = 1;
+      $self->$next($info);
+    };
+
+    __PACKAGE__->meta->make_immutable;
+
+    no Moose;
+}
+
 
 
 =head1 HOW TO USE
@@ -79,15 +95,8 @@ TESTSCHEMACLASSES: {
     ## Get the Schema and set the replication storage type
 
     sub init_schema {
-        # current SQLT SQLite producer does not handle DROP TABLE IF EXISTS, trap warnings here
-        local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /no such table.+DROP TABLE/s };
-
-        my ($class, $schema_method) = @_;
-
-        my $method = "get_schema_$schema_method";
-        my $schema = $class->$method;
-
-        return $schema;
+        #my ($class, $schema_getter) = @_;
+        shift->${\ ( 'get_schema_' . shift ) };
     }
 
     sub get_schema_by_storage_type {
@@ -131,27 +140,6 @@ TESTSCHEMACLASSES: {
     sub cleanup {}
 
     ## --------------------------------------------------------------------- ##
-    ## Add a connect_info option to test option merging.
-    ## --------------------------------------------------------------------- ##
-    {
-    package DBIx::Class::Storage::DBI::Replicated;
-
-    use Moose;
-
-    __PACKAGE__->meta->make_mutable;
-
-    around connect_info => sub {
-      my ($next, $self, $info) = @_;
-      $info->[3]{master_option} = 1;
-      $self->$next($info);
-    };
-
-    __PACKAGE__->meta->make_immutable;
-
-    no Moose;
-    }
-
-    ## --------------------------------------------------------------------- ##
     ## Subclass for when you are using SQLite for testing, this provides a fake
     ## replication support.
     ## --------------------------------------------------------------------- ##