forked from Caldrin/DBIx-Class
-
Notifications
You must be signed in to change notification settings - Fork 1
/
69update.t
36 lines (24 loc) · 969 Bytes
/
69update.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use strict;
use warnings;
use Test::More;
use lib qw(t/lib);
use DBICTest;
my $schema = DBICTest->init_schema();
BEGIN {
eval "use DBD::SQLite";
plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 6);
}
my $art = $schema->resultset("Artist")->find(1);
isa_ok $art => 'DBICTest::Artist';
my $name = 'Caterwauler McCrae';
ok($art->name($name) eq $name, 'update');
{
my @changed_keys = $art->is_changed;
is( scalar (@changed_keys), 0, 'field changed but same value' );
}
$art->discard_changes;
ok($art->update({ artistid => 100 }), 'update allows pk mutation');
is($art->artistid, 100, 'pk mutation applied');
my $art_100 = $schema->resultset("Artist")->find(100);
$art_100->artistid(101);
ok($art_100->update(), 'update allows pk mutation via column accessor');