X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F93storage_replication.t;h=a2463e4a625d209c29d19a7aba6fe75531fecf5c;hb=1da8d083227d3db4dee8f6392d7d06a66fd7155c;hp=40c24a5f57ace4017b5c796d460d6ed42d1bbbdd;hpb=ee356d004e088518205ac720b37c31a64c9cd861;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/93storage_replication.t b/t/93storage_replication.t index 40c24a5..a2463e4 100644 --- a/t/93storage_replication.t +++ b/t/93storage_replication.t @@ -6,12 +6,13 @@ use Test::Exception; use DBICTest; use List::Util 'first'; use Scalar::Util 'reftype'; +use IO::Handle; BEGIN { eval "use DBIx::Class::Storage::DBI::Replicated; use Test::Moose"; plan $@ ? ( skip_all => "Deps not installed: $@" ) - : ( tests => 89 ); + : ( tests => 90 ); } use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool'; @@ -360,13 +361,10 @@ is $artist1->name, 'Ozric Tentacles' ## Check that master_read_weight is honored { - no warnings 'once'; - - # turn off redefined warning - local $SIG{__WARN__} = sub {}; + no warnings qw/once redefine/; local - *DBIx::Class::Storage::DBI::Replicated::Balancer::Random::random_number = + *DBIx::Class::Storage::DBI::Replicated::Balancer::Random::_random_number = sub { 999 }; $replicated->schema->storage->balancer->increment_storage; @@ -469,13 +467,20 @@ ok $replicated->schema->resultset('Artist')->find(2) $replicated->schema->storage->replicants->{$replicant_names[0]}->active(0); $replicated->schema->storage->replicants->{$replicant_names[1]}->active(0); -## Silence warning about falling back to master. -$replicated->schema->storage->debugobj->silence(1); - -ok $replicated->schema->resultset('Artist')->find(2) - => 'Fallback to master'; +{ + ## catch the fallback to master warning + open my $debugfh, '>', \my $fallback_warning; + my $oldfh = $replicated->schema->storage->debugfh; + $replicated->schema->storage->debugfh($debugfh); -$replicated->schema->storage->debugobj->silence(0); + ok $replicated->schema->resultset('Artist')->find(2) + => 'Fallback to master'; + + like $fallback_warning, qr/falling back to master/ + => 'emits falling back to master warning'; + + $replicated->schema->storage->debugfh($oldfh); +} $replicated->schema->storage->replicants->{$replicant_names[0]}->active(1); $replicated->schema->storage->replicants->{$replicant_names[1]}->active(1);