From: Aaron Trevena Date: Tue, 4 Mar 2008 20:41:32 +0000 (+0000) Subject: roughly DTRT - please to be making less awful X-Git-Tag: v0.08240~546 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f7986d659a813f1dec169a7f57c38f956560ea4;p=dbsrgits%2FDBIx-Class.git roughly DTRT - please to be making less awful --- diff --git a/t/93storage_replication.t b/t/93storage_replication.t index f903ad4..34c0f48 100644 --- a/t/93storage_replication.t +++ b/t/93storage_replication.t @@ -7,7 +7,10 @@ use File::Copy; use DBICTest; use Test::More; -plan tests => 1; +eval {use DBD::Multi}; +plan skip_all => 'No DBD::Multi' if ($@); + +plan tests => 3; my $schema = DBICTest->init_schema(); @@ -33,14 +36,31 @@ $schema->populate('Artist', [ [ 4, 'Ozric Tentacles'] ]); -# try and read (should fail) -my $new_artist = $schema->resultset('Artist')->find(4); +my $new_artist1 = $schema->resultset('Artist')->find(4); + +isa_ok ($new_artist1, 'DBICTest::Artist'); -warn "artist : $new_artist\n"; +# reconnect +my $schema2 = $schema->connect( [ + [ $dsn1, '', '', { AutoCommit => 1 } ], + [ $dsn2, '', '', { priority => 10 } ], + [ $dsn3, '', '', { priority => 10 } ] + ] + ); + +# try and read (should fail) +eval { my $new_artist2 = $schema2->resultset('Artist')->find(4); }; +ok($@, 'read after disconnect fails because it uses slave 1 which we have neglected to "replicate" yet'); # try and read (should succede after faked synchronisation) copy($db_file1, $db_file2); +$schema2 = $schema->connect( [ + [ $dsn1, '', '', { AutoCommit => 1 } ], + [ $dsn2, '', '', { priority => 10 } ], + [ $dsn3, '', '', { priority => 10 } ] + ] + ); +my $new_artist3 = $schema2->resultset('Artist')->find(4); +isa_ok ($new_artist3, 'DBICTest::Artist'); unlink $db_file2; - -ok(1,"These aren't the tests you're looking for");