Factor out bindattr resolver and tighten code a bit
[dbsrgits/DBIx-Class.git] / t / relationship / doesnt_exist.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 => 3;
11
12 my $bookmark = $schema->resultset("Bookmark")->find(1);
13 my $link = $bookmark->link;
14 my $link_id = $link->id;
15 ok $link->id;
16
17 $link->delete;
18 is $schema->resultset("Link")->search({id => $link_id})->count, 0,
19     "link $link_id was deleted";
20
21 # Get a fresh object with nothing cached
22 $bookmark = $schema->resultset("Bookmark")->find($bookmark->id);
23
24 # This would create a new link row if none existed
25 $bookmark->link;
26
27 is $schema->resultset("Link")->search({id => $link_id})->count, 0,
28     'accessor did not create a link object where there was none';