X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F93storage_replication.t;h=7b70b94f4a58c45764b0ba180e1e6555118b84f8;hb=9c169362528768554474ce1018a698ac0cbcd50f;hp=1a6a3f3755e6c78575757cfaf66cec4806e5ba8d;hpb=494674a52f9976f723d838cdfa96ab9b394b1c6e;p=dbsrgits%2FDBIx-Class.git diff --git a/t/93storage_replication.t b/t/93storage_replication.t index 1a6a3f3..7b70b94 100644 --- a/t/93storage_replication.t +++ b/t/93storage_replication.t @@ -6,13 +6,14 @@ use Test::Exception; use DBICTest; use List::Util 'first'; use Scalar::Util 'reftype'; +use File::Spec; use IO::Handle; BEGIN { eval "use DBIx::Class::Storage::DBI::Replicated; use Test::Moose"; plan $@ ? ( skip_all => "Deps not installed: $@" ) - : ( tests => 126 ); + : ( tests => 130 ); } use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool'; @@ -20,6 +21,10 @@ use_ok 'DBIx::Class::Storage::DBI::Replicated::Balancer'; use_ok 'DBIx::Class::Storage::DBI::Replicated::Replicant'; use_ok 'DBIx::Class::Storage::DBI::Replicated'; +use Moose(); +use MooseX::Types(); +diag "Using Moose version $Moose::VERSION and MooseX::Types version $MooseX::Types::VERSION"; + =head1 HOW TO USE This is a test of the replicated storage system. This will work in one of @@ -142,9 +147,9 @@ TESTSCHEMACLASSES: { use File::Copy; use base 'DBIx::Class::DBI::Replicated::TestReplication'; - __PACKAGE__->mk_accessors( qw/master_path slave_paths/ ); + __PACKAGE__->mk_accessors(qw/master_path slave_paths/); - ## Set the mastep path from DBICTest + ## Set the master path from DBICTest sub new { my $class = shift @_; @@ -152,9 +157,9 @@ TESTSCHEMACLASSES: { $self->master_path( DBICTest->_sqlite_dbfilename ); $self->slave_paths([ - "t/var/DBIxClass_slave1.db", - "t/var/DBIxClass_slave2.db", - ]); + File::Spec->catfile(qw/t var DBIxClass_slave1.db/), + File::Spec->catfile(qw/t var DBIxClass_slave2.db/), + ]); return $self; } @@ -170,7 +175,10 @@ TESTSCHEMACLASSES: { my @connect_infos = map { [$_,'','',{AutoCommit=>1}] } @dsn; - # try a hashref too + ## Make sure nothing is left over from a failed test + $self->cleanup; + + ## try a hashref too my $c = $connect_infos[0]; $connect_infos[0] = { dsn => $c->[0], @@ -198,7 +206,9 @@ TESTSCHEMACLASSES: { sub cleanup { my $self = shift @_; foreach my $slave (@{$self->slave_paths}) { - unlink $slave; + if(-e $slave) { + unlink $slave; + } } } @@ -751,10 +761,19 @@ 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}"; ok $artist->get_from_storage({force_pool=>'master'}) - => 'properly discard changes'; + => 'properly called get_from_storage against master (manual attrs)'; + + is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}"; + + ok $artist->discard_changes({force_pool=>'master'}) + => 'properly alled discard_changes against master (manual attrs)'; is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}"; + ok $artist->discard_changes() + => 'properly alled discard_changes against master (default attrs)'; + + is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}" } ## Test some edge cases, like trying to do a transaction inside a transaction, etc