Merge branch 'current/for_cpan_index' into current/dq
[dbsrgits/DBIx-Class.git] / t / storage / replicated.t
index cadd085..509b3e6 100644 (file)
@@ -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 DBIx::Class::Storage::DBI::Replicated::Pool;
-use DBIx::Class::Storage::DBI::Replicated::Balancer;
-use DBIx::Class::Storage::DBI::Replicated::Replicant;
+## 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
@@ -124,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.
     ## --------------------------------------------------------------------- ##
@@ -209,10 +204,11 @@ TESTSCHEMACLASSES: {
         }
     }
 
-    ## Cleanup after ourselves.  Unlink all gthe slave paths.
+    ## Cleanup after ourselves. Unlink all the slave paths.
 
     sub cleanup {
         my $self = shift @_;
+        $_->disconnect for values %{ $self->schema->storage->replicants };
         foreach my $slave (@{$self->slave_paths}) {
             if(-e $slave) {
                 unlink $slave;
@@ -917,6 +913,7 @@ is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{d
 
     is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
 }
+
 ## Delete the old database files
 $replicated->cleanup;