Institute a central "load this first in testing" package
[dbsrgits/DBIx-Class.git] / t / resultsource / set_primary_key.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
3 use strict;
4 use warnings;
5 use Test::More;
6 use Test::Exception;
7 use Test::Warn;
8
9
10 use DBICTest;
11
12 throws_ok {
13   package Foo;
14   use base 'DBIx::Class::Core';
15   __PACKAGE__->table('foo');
16   __PACKAGE__->set_primary_key('bar')
17 } qr/No such column 'bar' on source 'foo' /,
18 'proper exception on non-existing column as PK';
19
20 warnings_exist {
21   package Foo2;
22   use base 'DBIx::Class::Core';
23   __PACKAGE__->table('foo');
24   __PACKAGE__->add_columns(
25     foo => {},
26     bar => { is_nullable => 1 },
27   );
28   __PACKAGE__->set_primary_key(qw(foo bar))
29 } qr/Primary key of source 'foo' includes the column 'bar' which has its 'is_nullable' attribute set to true/,
30 'proper exception on is_nullable column as PK';
31
32 done_testing;