[Bast-commits] r4122 - DBIx-Class/0.08/trunk/t

teejay at dev.catalyst.perl.org teejay at dev.catalyst.perl.org
Tue Mar 4 20:41:32 GMT 2008


Author: teejay
Date: 2008-03-04 20:41:32 +0000 (Tue, 04 Mar 2008)
New Revision: 4122

Modified:
   DBIx-Class/0.08/trunk/t/93storage_replication.t
Log:
roughly DTRT - please to be making less awful

Modified: DBIx-Class/0.08/trunk/t/93storage_replication.t
===================================================================
--- DBIx-Class/0.08/trunk/t/93storage_replication.t	2008-03-04 20:18:45 UTC (rev 4121)
+++ DBIx-Class/0.08/trunk/t/93storage_replication.t	2008-03-04 20:41:32 UTC (rev 4122)
@@ -7,8 +7,11 @@
 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();
 
 $schema->storage_type( '::DBI::Replication' );
@@ -33,14 +36,31 @@
 			     [ 4, 'Ozric Tentacles']
 			    ]);
 
+my $new_artist1 = $schema->resultset('Artist')->find(4);
+
+isa_ok ($new_artist1, 'DBICTest::Artist');
+
+# reconnect
+my $schema2 = $schema->connect( [
+				 [ $dsn1, '', '', { AutoCommit => 1 } ],
+				 [ $dsn2, '', '', { priority => 10 } ],
+				 [ $dsn3, '', '', { priority => 10 } ]
+				]
+			      );
+
 # try and read (should fail)
-my $new_artist = $schema->resultset('Artist')->find(4);
+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');
 
-warn "artist : $new_artist\n";
-
 # 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");




More information about the Bast-commits mailing list