Rename some variables and reformat the FC/IC codepaths for clarity
[dbsrgits/DBIx-Class.git] / t / multi_create / standard.t
index 263eec2..6c1efd8 100644 (file)
@@ -112,7 +112,7 @@ lives_ok ( sub {
 #                                               /
 #                                          Producer
 lives_ok ( sub {
-  my $artist = $schema->resultset('Artist')->first;
+  my $artist = $schema->resultset('Artist')->find(1);
   my $cd = $schema->resultset('CD')->create ({
     artist => $artist,
     title => 'Music to code by at night',
@@ -152,7 +152,7 @@ lives_ok ( sub {
   is ($cd->title, 'Music to code by at night', 'Correct CD title');
   is ($cd->tracks->count, 2, 'Two tracks on main CD');
 
-  my ($t1, $t2) = $cd->tracks->all;
+  my ($t1, $t2) = sort { $a->id <=> $b->id } $cd->tracks->all;
   is ($t1->title, 'Off by one again', 'Correct 1st track name');
   is ($t1->cd_single, undef, 'No single for 1st track');
   is ($t2->title, 'The dereferencer', 'Correct 2nd track name');
@@ -405,10 +405,10 @@ lives_ok ( sub {
 
 
   $schema->resultset('Artist')->populate([ $kurt_cobain ]); # %)
-  $a = $schema->resultset('Artist')->find({name => 'Kurt Cobain'});
+  my $artist = $schema->resultset('Artist')->find({name => 'Kurt Cobain'});
 
-  is($a->name, 'Kurt Cobain', 'Artist insertion ok');
-  is($a->cds && $a->cds->first && $a->cds->first->title,
+  is($artist->name, 'Kurt Cobain', 'Artist insertion ok');
+  is($artist->cds && $artist->cds->first && $artist->cds->first->title,
       'In Utero', 'CD insertion ok');
 }, 'populate');
 
@@ -444,7 +444,11 @@ throws_ok ( sub {
     #$t->cd($t->new_related('cd', { artist => undef } ) );
     #$t->{_rel_in_storage} = 0;
     $t->insert;
-}, qr/cd.artist may not be NULL/, "Exception propogated properly");
+}, qr/DBI Exception.+(?x:
+    \QNOT NULL constraint failed: cd.artist\E
+      |
+    \Qcd.artist may not be NULL\E
+)/s, "Exception propogated properly");
 
 lives_ok ( sub {
   $schema->resultset('CD')->create ({