use File::Temp;
use Test::More qw(no_plan);
use Test::Exception;
+use LoadTest;
use Devel::Dwarn;
BEGIN {
- use_ok 'MTITest';
$ENV{DBIC_TRACE} = 0;
}
-dies_ok { MTITest->source('Foo')->view_definition }
+my ( $dsn, $user, $pass )
+ = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ };
+
+plan skip_all => <<'EOM' unless $dsn && $user;
+Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test
+( NOTE: This test drops and creates some tables.')
+EOM
+
+dies_ok { LoadTest->source('Foo')->view_definition }
"Can't generate view def without connected schema";
-my $schema = MTITest->connect( 'dbi:Pg:dbname=test', 'postgres', '' );
+my $schema = LoadTest->connect( $dsn, $user, $pass );
+$schema->storage->ensure_connected;
my $dir = "t/sql"; # tempdir(CLEANUP => 0);
-#$schema->storage->dbh->{Warn} = 0;
-$schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir );
-$schema->deploy( { add_drop_table => 1, add_drop_view => 1} );
+lives_ok { $schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ) }
+"It's OK to create_ddl_dir";
+lives_ok {
+ $schema->deploy( { add_drop_table => 1, add_drop_view => 1, } );
+}
+"It's also OK to deploy the schema";
+
+isa_ok(
+ $schema->source('Bar'),
+ 'DBIx::Class::ResultSource::View',
+ "My MTI class also"
+);
+
+my $sqlt_object = $schema->{sqlt};
+
+is_deeply(
+ [ map { $_->name } $sqlt_object->get_views ],
+ [ qw/
+ foo
+ bar
+ /
+ ],
+ "SQLT view order triumphantly matches our order."
+);
+