fix old class replace regex, new TODO
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 12pg_common.t
CommitLineData
a78e3fed 1use strict;
c2849787 2use lib qw(t/lib);
fbd83464 3use dbixcsl_common_tests;
fdd8ff16 4use Test::More;
a78e3fed 5
9e978a19 6my $dsn = $ENV{DBICTEST_PG_DSN} || '';
7my $user = $ENV{DBICTEST_PG_USER} || '';
8my $password = $ENV{DBICTEST_PG_PASS} || '';
a78e3fed 9
fbd83464 10my $tester = dbixcsl_common_tests->new(
a78e3fed 11 vendor => 'Pg',
12 auto_inc_pk => 'SERIAL NOT NULL PRIMARY KEY',
9e978a19 13 dsn => $dsn,
a78e3fed 14 user => $user,
15 password => $password,
fdd8ff16 16 extra => {
17 create => [
18 q{
19 CREATE TABLE pg_loader_test1 (
20 id SERIAL NOT NULL PRIMARY KEY,
21 value VARCHAR(100)
22 )
23 },
24 q{
25 COMMENT ON TABLE pg_loader_test1 IS 'The Table'
26 },
27 q{
28 COMMENT ON COLUMN pg_loader_test1.value IS 'The Column'
29 },
30 ],
31 drop => [ qw/ pg_loader_test1 / ],
32 count => 2,
33 run => sub {
34 my ($schema, $monikers, $classes) = @_;
35
36 my $class = $classes->{pg_loader_test1};
37 my $filename = $schema->_loader->_get_dump_filename($class);
38
39 my $code = do {
40 local ($/, @ARGV) = (undef, $filename);
41 <>;
42 };
43
44 like $code, qr/^=head1 NAME\n\n^$class - The Table\n\n^=cut\n/m,
45 'table comment';
46
79a00530 47 like $code, qr/^=head2 value\n\n(.+:.+\n)+\nThe Column\n\n/m,
48 'column comment and attrs';
fdd8ff16 49 },
50 },
a78e3fed 51);
52
9e978a19 53if( !$dsn || !$user ) {
54 $tester->skip_tests('You need to set the DBICTEST_PG_DSN, _USER, and _PASS environment variables');
a78e3fed 55}
56else {
57 $tester->run_tests();
58}