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