Release 0.02
[dbsrgits/DBIx-Class-ResultSource-MultipleTableInheritance.git] / t / 02view_def.t
CommitLineData
487f4489 1use strict;
2use warnings;
3use lib 't/lib';
8b229aa6 4use File::Temp;
0906c32b 5use Test::More tests => 5;
487f4489 6use Test::Exception;
4eaa25b5 7use LoadTest;
487f4489 8
8f839b1c 9BEGIN {
ebcd7e95 10 $ENV{DBIC_TRACE} = 0;
8f839b1c 11}
487f4489 12
32098147 13my ( $dsn, $user, $pass )
14 = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ };
15
16plan skip_all => <<'EOM' unless $dsn && $user;
17Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test
18( NOTE: This test drops and creates some tables.')
19EOM
20
4eaa25b5 21dies_ok { LoadTest->source('Foo')->view_definition }
8f839b1c 22"Can't generate view def without connected schema";
487f4489 23
4eaa25b5 24my $schema = LoadTest->connect( $dsn, $user, $pass );
b5c5e046 25$schema->storage->ensure_connected;
c965b761 26$schema->storage->dbh->{Warn} = 0;
c8e085ba 27
8f839b1c 28my $dir = "t/sql"; # tempdir(CLEANUP => 0);
29
32098147 30lives_ok { $schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ) }
31"It's OK to create_ddl_dir";
32lives_ok {
4eaa25b5 33 $schema->deploy( { add_drop_table => 1, add_drop_view => 1, } );
32098147 34}
35"It's also OK to deploy the schema";
3365fc70 36
b5c5e046 37isa_ok(
38 $schema->source('Bar'),
39 'DBIx::Class::ResultSource::View',
40 "My MTI class also"
41);
42
3365fc70 43my $sqlt_object = $schema->{sqlt};
44
45is_deeply(
46 [ map { $_->name } $sqlt_object->get_views ],
47 [ qw/
48 foo
49 bar
50 /
51 ],
52 "SQLT view order triumphantly matches our order."
53);
54