Commit | Line | Data |
7a72e5a5 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
8 | my $tests = 3; |
9 | plan tests => $tests; |
10 | |
11 | my $schema = DBICTest->init_schema(); |
12 | my $rs = $schema->resultset ('Artist'); |
13 | my $last_obj = $rs->search ({}, { order_by => { -desc => 'artistid' }, rows => 1})->single; |
14 | my $last_id = $last_obj ? $last_obj->artistid : 0; |
15 | |
16 | my $obj; |
17 | eval { $obj = $rs->create ({}) }; |
18 | my $err = $@; |
19 | |
20 | ok ($obj, 'Insert defaults ( $rs->create ({}) )' ); |
21 | SKIP: { |
22 | skip "Default insert failed: $err", $tests-1 if $err; |
23 | |
24 | # this should be picked up without calling the DB again |
25 | is ($obj->artistid, $last_id + 1, 'Autoinc PK works'); |
26 | |
27 | # for this we need to refresh |
28 | $obj->discard_changes; |
29 | is ($obj->rank, 13, 'Default value works'); |
30 | } |
31 | |