Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / 94pk_mutation.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
729b29ae 3use strict;
8273e845 4use warnings;
729b29ae 5
6use Test::More;
c0329273 7
729b29ae 8use DBICTest;
9
10my $schema = DBICTest->init_schema();
11
12plan tests => 10;
13
14my $old_artistid = 1;
15my $new_artistid = $schema->resultset("Artist")->get_column('artistid')->max + 1;
16
17# Update the PK
18{
19 my $artist = $schema->resultset("Artist")->find($old_artistid);
20 ok(defined $artist, 'found an artist with the new PK');
21
22 $artist->update({ artistid => $new_artistid });
23 is($artist->artistid, $new_artistid, 'artist ID matches');
24}
25
26# Look for the old PK
27{
28 my $artist = $schema->resultset("Artist")->find($old_artistid);
29 ok(!defined $artist, 'no artist found with the old PK');
30}
31
32# Look for the new PK
33{
34 my $artist = $schema->resultset("Artist")->find($new_artistid);
35 ok(defined $artist, 'found an artist with the new PK');
36 is($artist->artistid, $new_artistid, 'artist ID matches');
37}
38
39# Do it all over again, using a different methodology:
40$old_artistid = $new_artistid;
41$new_artistid++;
42
43# Update the PK
44{
45 my $artist = $schema->resultset("Artist")->find($old_artistid);
46 ok(defined $artist, 'found an artist with the new PK');
47
48 $artist->artistid($new_artistid);
49 $artist->update;
50 is($artist->artistid, $new_artistid, 'artist ID matches');
51}
52
53# Look for the old PK
54{
55 my $artist = $schema->resultset("Artist")->find($old_artistid);
56 ok(!defined $artist, 'no artist found with the old PK');
57}
58
59# Look for the new PK
60{
61 my $artist = $schema->resultset("Artist")->find($new_artistid);
62 ok(defined $artist, 'found an artist with the new PK');
63 is($artist->artistid, $new_artistid, 'artist ID matches');
64}