Don't blow up if columns_info_for returns useless results
[dbsrgits/DBIx-Class.git] / t / 94pk_mutation.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my $schema = DBICTest->init_schema();
9
10 plan tests => 5;
11
12 my $old_artistid = 1;
13 my $new_artistid = $schema->resultset("Artist")->get_column('artistid')->max + 1;
14
15 # Update the PK
16 {
17   my $artist = $schema->resultset("Artist")->find($old_artistid);
18   ok(defined $artist, 'found an artist with the new PK');
19
20   $artist->update({ artistid => $new_artistid });
21   is($artist->artistid, $new_artistid, 'artist ID matches');
22 }
23
24 # Look for the old PK
25 {
26   my $artist = $schema->resultset("Artist")->find($old_artistid);
27   ok(!defined $artist, 'no artist found with the old PK');
28 }
29
30 # Look for the new PK
31 {
32   my $artist = $schema->resultset("Artist")->find($new_artistid);
33   ok(defined $artist, 'found an artist with the new PK');
34   is($artist->artistid, $new_artistid, 'artist ID matches');
35 }