Make sure sqlt_type gets called after determining driver
[dbsrgits/DBIx-Class-Historic.git] / t / 72pg.t
index 0fc3f3d..e382a87 100644 (file)
--- a/t/72pg.t
+++ b/t/72pg.t
@@ -1,5 +1,5 @@
 use strict;
-use warnings;  
+use warnings;
 
 use Test::More;
 use Test::Exception;
@@ -49,12 +49,16 @@ plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test '.
   ' as well as following schemas: \'testschema\',\'anothertestschema\'!)'
     unless ($dsn && $user);
 
+DBICTest::Schema->load_classes( 'Casecheck', 'ArrayTest' );
 
-plan tests => 42;
+{
+  my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
 
-DBICTest::Schema->load_classes( 'Casecheck', 'ArrayTest' );
-my $schema = DBICTest::Schema->connect($dsn, $user, $pass,);
+  ok (!$schema->storage->_dbh, 'definitely not connected');
+  is ($schema->storage->sqlt_type, 'PostgreSQL', 'sqlt_type correct pre-connection');
+}
 
+my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
 # Check that datetime_parser returns correctly before we explicitly connect.
 SKIP: {
     eval { require DateTime::Format::Pg };
@@ -122,6 +126,17 @@ cmp_ok( $schema->resultset('Artist')->count, '==', 0, 'this should start with an
 
   is($unq_new && $unq_new->artistid, 1, "and got correct artistid");
 
+  #test with anothertestschema
+  $schema->source('Artist')->name('anothertestschema.artist');
+  my $another_new = $schema->resultset('Artist')->create({ name => 'ribasushi'});
+  is( $another_new->artistid,1, 'got correct artistid for yetanotherschema');
+
+  #test with yetanothertestschema
+  $schema->source('Artist')->name('yetanothertestschema.artist');
+  my $yetanother_new = $schema->resultset('Artist')->create({ name => 'ribasushi'});
+  is( $yetanother_new->artistid,1, 'got correct artistid for yetanotherschema');
+  is( $yetanother_new->artistid,1, 'got correct artistid for yetanotherschema');
+
   $schema->source("Artist")->name($artist_name_save);
 }
 
@@ -321,4 +336,6 @@ sub _cleanup {
   }
 }
 
+done_testing;
+
 END { _cleanup($dbh) }