X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=t%2F93storage_replication.t;h=eb31c816cff37b9c9d8258da790d698aebc67c28;hp=26f60394c4bd9e7a0888b284e086d6bd2f7712bf;hb=de5dc9efd2c3575f78a7dc71c50d571c9a17c38d;hpb=8871d4ad1ce3afa80338d355a21ba28d9b4a46ca diff --git a/t/93storage_replication.t b/t/93storage_replication.t index 26f6039..eb31c81 100644 --- a/t/93storage_replication.t +++ b/t/93storage_replication.t @@ -5,10 +5,10 @@ use Test::More; use DBICTest; BEGIN { - eval "use Moose"; + eval "use Moose; use Test::Moose"; plan $@ ? ( skip_all => 'needs Moose for testing' ) - : ( tests => 40 ); + : ( tests => 41 ); } use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool'; @@ -213,18 +213,18 @@ ok $replicated->schema->storage->pool->has_replicants is $replicated->schema->storage->num_replicants => 2 => 'has two replicants'; -isa_ok $replicated_storages[0] +does_ok $replicated_storages[0] => 'DBIx::Class::Storage::DBI::Replicated::Replicant'; -isa_ok $replicated_storages[1] +does_ok $replicated_storages[1] => 'DBIx::Class::Storage::DBI::Replicated::Replicant'; my @replicant_names = keys %{$replicated->schema->storage->replicants}; - -isa_ok $replicated->schema->storage->replicants->{$replicant_names[0]} + +does_ok $replicated->schema->storage->replicants->{$replicant_names[0]} => 'DBIx::Class::Storage::DBI::Replicated::Replicant'; -isa_ok $replicated->schema->storage->replicants->{$replicant_names[1]} +does_ok $replicated->schema->storage->replicants->{$replicant_names[1]} => 'DBIx::Class::Storage::DBI::Replicated::Replicant'; ## Add some info to the database @@ -355,7 +355,19 @@ $replicated->schema->storage->replicants->{$replicant_names[0]}->active(0); $replicated->schema->storage->replicants->{$replicant_names[1]}->active(0); ok $replicated->schema->resultset('Artist')->find(2) - => 'Fallback to master'; + => 'Fallback to master'; + +$replicated->schema->storage->replicants->{$replicant_names[0]}->active(1); +$replicated->schema->storage->replicants->{$replicant_names[1]}->active(1); + +ok $replicated->schema->resultset('Artist')->find(2) + => 'Returned to replicates'; + +## Getting slave status tests + +use Data::Dump qw/dump/; +my $lag1 = $replicated->schema->storage->replicants->{$replicant_names[0]}->lag_behind_master; +warn dump $lag1; ## Delete the old database files $replicated->cleanup;