X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest.pm;h=39a8af926c088f30775b455679b96c8967ea4f68;hb=8b60b9211a;hp=f2b27733fa5230912816309669014ac7772eabc1;hpb=7d6c28b70b4c37d6296ea4a17ac919799b3a8bc2;p=dbsrgits%2FDBIx-Class.git diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index f2b2773..39a8af9 100644 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -219,7 +219,7 @@ sub _database { # set a *DBI* disconnect callback, to make sure the physical SQLite # file is still there (i.e. the test does not attempt to delete # an open database, which fails on Win32) - if (my $guard_cb = __mk_disconnect_guard($db_file)) { + if (! $storage->{master} and my $guard_cb = __mk_disconnect_guard($db_file)) { $dbh->{Callbacks} = { connect => sub { $guard_cb->('connect') }, disconnect => sub { $guard_cb->('disconnect') }, @@ -320,6 +320,14 @@ sub init_schema { my $schema; + if ( + $ENV{DBICTEST_VIA_REPLICATED} &&= + ( !$args{storage_type} && !defined $args{sqlite_use_file} ) + ) { + $args{storage_type} = ['::DBI::Replicated', { balancer_type => '::Random' }]; + $args{sqlite_use_file} = 1; + } + my @dsn = $self->_database(%args); if ($args{compose_connection}) { @@ -337,6 +345,9 @@ sub init_schema { if ( !$args{no_connect} ) { $schema->connection(@dsn); + + $schema->storage->connect_replicants(\@dsn) + if $ENV{DBICTEST_VIA_REPLICATED}; } if ( !$args{no_deploy} ) {