X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F72pg.t;h=40ba3d384eaa7c604fb8b87135ba322080bf211f;hb=eb304a6408bf3b50f070f7c585bd825da6e2c38b;hp=0fc3f3d1b0448c0a97d46d67849ad0f39dca4d7b;hpb=46bb5b38b2c2090d73675e4fae2f8ffcb6eee1e6;p=dbsrgits%2FDBIx-Class.git diff --git a/t/72pg.t b/t/72pg.t index 0fc3f3d..40ba3d3 100644 --- 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,17 @@ 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; +# make sure sqlt_type overrides work (::Storage::DBI::Pg does this) +{ + 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 }; @@ -72,7 +77,7 @@ $schema->source("Artist")->name("testschema.artist"); $schema->source("SequenceTest")->name("testschema.sequence_test"); { local $SIG{__WARN__} = sub {}; - _cleanup ($dbh); + _cleanup ($schema); my $artist_table_def = <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); } @@ -301,24 +317,21 @@ my $st = $schema->resultset('SequenceTest')->create({ name => 'foo', pkid1 => 55 is($st->pkid1, 55, "Oracle Auto-PK without trigger: First primary key set manually"); sub _cleanup { - my $dbh = shift or return; + my $schema = shift or return; + local $SIG{__WARN__} = sub {}; for my $stat ( - 'DROP TABLE testschema.artist', - 'DROP TABLE testschema.casecheck', - 'DROP TABLE testschema.sequence_test', - 'DROP TABLE testschema.array_test', + 'DROP SCHEMA testschema CASCADE', + 'DROP SCHEMA anothertestschema CASCADE', + 'DROP SCHEMA yetanothertestschema CASCADE', 'DROP SEQUENCE pkid1_seq', 'DROP SEQUENCE pkid2_seq', 'DROP SEQUENCE nonpkid_seq', - 'DROP SCHEMA testschema', - 'DROP TABLE anothertestschema.artist', - 'DROP SCHEMA anothertestschema', - 'DROP TABLE yetanothertestschema.artist', - 'DROP SCHEMA yetanothertestschema', ) { - eval { $dbh->do ($stat) }; + eval { $schema->storage->_do_query ($stat) }; } } -END { _cleanup($dbh) } +done_testing; + +END { _cleanup($schema) }