[Bast-commits] r5275 - DBIx-Class/0.08/branches/result_source_sqlt_deploy_hook/t

nothingmuch at dev.catalyst.perl.org nothingmuch at dev.catalyst.perl.org
Mon Dec 22 02:17:45 GMT 2008


Author: nothingmuch
Date: 2008-12-22 02:17:45 +0000 (Mon, 22 Dec 2008)
New Revision: 5275

Modified:
   DBIx-Class/0.08/branches/result_source_sqlt_deploy_hook/t/86sqlt.t
Log:
test for result source hook

Modified: DBIx-Class/0.08/branches/result_source_sqlt_deploy_hook/t/86sqlt.t
===================================================================
--- DBIx-Class/0.08/branches/result_source_sqlt_deploy_hook/t/86sqlt.t	2008-12-22 02:17:39 UTC (rev 5274)
+++ DBIx-Class/0.08/branches/result_source_sqlt_deploy_hook/t/86sqlt.t	2008-12-22 02:17:45 UTC (rev 5275)
@@ -10,7 +10,7 @@
 
 my $schema = DBICTest->init_schema;
 
-plan tests => 131;
+plan tests => 132;
 
 my $translator = SQL::Translator->new( 
   parser_args => {
@@ -26,6 +26,17 @@
     my $relinfo = $schema->source('Artist')->relationship_info ('cds');
     local $relinfo->{attrs}{on_delete} = 'restrict';
 
+    $schema->source('Track')->sqlt_deploy_callback(sub {
+      my ($self, $sqlt_table) = @_;
+
+      if ($sqlt_table->schema->translator->producer_type =~ /SQLite$/ ) {
+        $sqlt_table->add_index( name => 'track_title', fields => ['title'] )
+          or die $sqlt_table->error;
+      }
+
+      $self->default_sqlt_deploy_hook($sqlt_table);
+    });
+
     $translator->parser('SQL::Translator::Parser::DBIx::Class');
     $translator->producer('SQLite');
 
@@ -258,7 +269,12 @@
     {
       'fields' => ['name']
     },
-  ]
+  ],
+  track => [
+    {
+      'fields' => ['title']
+    }
+  ],
 );
 
 my $tschema = $translator->schema();
@@ -300,7 +316,6 @@
 
 for my $table_index (keys %indexes) {
   for my $expected_index ( @{ $indexes{$table_index} } ) {
-
     ok ( get_index($table_index, $expected_index), "Got a matching index on $table_index table");
   }
 }




More information about the Bast-commits mailing list