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