X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F93storage_replication.t;h=62a4d1549f31ba5e084755550f595c9eca6729e9;hb=2156bbddf88e67ebe429789d0018c708cddfcbe4;hp=fd2241d9bb72805fef4e66cedbaf0ef5b89edc85;hpb=0f83441a23e70b5b9e68ae3002cc63b8cf4e8698;p=dbsrgits%2FDBIx-Class.git diff --git a/t/93storage_replication.t b/t/93storage_replication.t index fd2241d..62a4d15 100644 --- a/t/93storage_replication.t +++ b/t/93storage_replication.t @@ -2,13 +2,12 @@ use strict; use warnings; use lib qw(t/lib); use Test::More; -use Data::Dump qw/dump/; BEGIN { eval "use DBD::Multi"; plan $@ ? ( skip_all => 'needs DBD::Multi for testing' ) - : ( tests => 18 ); + : ( tests => 20 ); } ## ---------------------------------------------------------------------------- @@ -17,7 +16,7 @@ BEGIN { TESTSCHEMACLASS: { - package DBIx::Class::DBI::Replication::TestReplication; + package DBIx::Class::DBI::Replicated::TestReplication; use DBI; use DBICTest; @@ -58,7 +57,7 @@ TESTSCHEMACLASS: { sub init_schema { my $class = shift @_; my $schema = DBICTest->init_schema(); - $schema->storage_type( '::DBI::Replication' ); + $schema->storage_type( '::DBI::Replicated' ); return $schema; } @@ -68,15 +67,15 @@ TESTSCHEMACLASS: { sub connect { my $self = shift @_; my ($master, @slaves) = @{$self->{dsns}}; - my @connections = ([$master, '','', {AutoCommit=>1, PrintError=>0}]); - my @slavesob; + my $master_connect_info = [$master, '','', {AutoCommit=>1, PrintError=>0}]; + my @slavesob; foreach my $slave (@slaves) { my $dbh = shift @{$self->{slaves}} || DBI->connect($slave,"","",{PrintError=>0, PrintWarn=>0}); - push @connections, + push @{$master_connect_info->[-1]->{slaves_connect_info}}, [$dbh, '','',{priority=>10}]; push @slavesob, @@ -88,10 +87,7 @@ TESTSCHEMACLASS: { $self ->{schema} - ->connect([ - @connections, - {limit_dialect => 'LimitXY'} - ]); + ->connect(@$master_connect_info); } ## replication @@ -138,7 +134,7 @@ my %params = ( ], ); -ok my $replicate = DBIx::Class::DBI::Replication::TestReplication->new(%params) +ok my $replicate = DBIx::Class::DBI::Replicated::TestReplication->new(%params) => 'Created a replication object'; isa_ok $replicate->{schema} @@ -172,13 +168,6 @@ is $artist1->name, 'Ozric Tentacles' ## we overload any type of write operation so that is must hit the master ## database. -use Fcntl qw (:flock); - -my $master_path = $replicate->{db_paths}->[0]; -open LOCKFILE, ">>$master_path" - or die "Cannot open $master_path"; -flock(LOCKFILE, LOCK_EX); - $replicate ->{schema} ->populate('Artist', [ @@ -256,6 +245,20 @@ eval { ok $@ => 'Got read errors after everything failed'; +## make sure ->connect_info returns something sane + +ok $replicate->{schema}->storage->connect_info + => 'got something out of ->connect_info'; + +## Force a connection to the write source for testing. + +$replicate->{schema}->storage($replicate->{schema}->storage->write_source); + +## What happens when we do a find for something that doesn't exist? + +ok ! $replicate->{schema}->resultset('Artist')->find(666) + => 'Correctly did not find a bad artist id'; + ## Delete the old database files $replicate->cleanup;