3cda01df60718823846d189bbdcf1e2a63dc86b0
[dbsrgits/DBIx-Class-ResultSource-MultipleTableInheritance.git] / t / 02view_def.t
1 use strict;
2 use warnings;
3 use lib 't/lib';
4 use File::Temp;
5 use Test::More qw(no_plan);
6 use Test::Exception;
7 use Devel::Dwarn;
8
9 BEGIN {
10     use_ok 'MTITest';
11     $ENV{DBIC_TRACE} = 0;
12 }
13
14 my ( $dsn, $user, $pass )
15     = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ };
16
17 plan skip_all => <<'EOM' unless $dsn && $user;
18 Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test
19 ( NOTE: This test drops and creates some tables.')
20 EOM
21
22 dies_ok { MTITest->source('Foo')->view_definition }
23 "Can't generate view def without connected schema";
24
25 my $schema = MTITest->connect( $dsn, $user, $pass );
26
27 my $dir = "t/sql";    # tempdir(CLEANUP => 0);
28
29 $schema->storage->dbh->{Warn} = 0;
30 lives_ok { $schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ) }
31 "It's OK to create_ddl_dir";
32 lives_ok {
33     $schema->deploy(
34         { add_drop_table => 1, add_drop_view => 1, } );
35 }
36 "It's also OK to deploy the schema";