X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F10_03pg_common.t;h=0225b336ad78eecd4c24dd0480056fe094d59642;hb=605be787558cfcee1aec714a6df0d0091a654e4d;hp=477ff0a8043fe1c4a634f9528cc68e75e5ab3234;hpb=ce2f102ae599b698ade7b725358294e99e72fe97;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/10_03pg_common.t b/t/10_03pg_common.t index 477ff0a..0225b33 100644 --- a/t/10_03pg_common.t +++ b/t/10_03pg_common.t @@ -1,3 +1,6 @@ +use DBIx::Class::Schema::Loader::Optional::Dependencies + -skip_all_without => 'test_rdbms_pg'; + use strict; use warnings; use utf8; @@ -19,7 +22,7 @@ my $dsn = $ENV{DBICTEST_PG_DSN} || ''; my $user = $ENV{DBICTEST_PG_USER} || ''; my $password = $ENV{DBICTEST_PG_PASS} || ''; -my $tester = dbixcsl_common_tests->new( +dbixcsl_common_tests->new( vendor => 'Pg', auto_inc_pk => 'SERIAL NOT NULL PRIMARY KEY', dsn => $dsn, @@ -246,6 +249,34 @@ my $tester = dbixcsl_common_tests->new( create view pg_loader_test11 as select * from pg_loader_test1 }, + q{ + create table pg_loader_test12 ( + id integer not null, + value integer, + active boolean, + name text + ) + }, + q{ + create unique index uniq_id_lc_name on pg_loader_test12 ( + id, lower(name) + ) + }, + q{ + create unique index uniq_uc_name_id on pg_loader_test12 ( + upper(name), id + ) + }, + q{ + create unique index pg_loader_test12_value on pg_loader_test12 ( + value + ) + }, + q{ + create unique index pg_loader_test12_name_active on pg_loader_test12 ( + name + ) where active + }, ], pre_drop_ddl => [ 'DROP SCHEMA dbicsl_test CASCADE', @@ -254,8 +285,8 @@ my $tester = dbixcsl_common_tests->new( 'DROP TYPE pg_loader_test_enum', 'DROP VIEW pg_loader_test11', ], - drop => [ qw/pg_loader_test1 pg_loader_test2 pg_loader_test9 pg_loader_test10/ ], - count => 9 + 30 * 2, + drop => [ qw/pg_loader_test1 pg_loader_test2 pg_loader_test9 pg_loader_test10 pg_loader_test12/ ], + count => 10 + 30 * 2, run => sub { my ($schema, $monikers, $classes) = @_; @@ -449,16 +480,14 @@ my $tester = dbixcsl_common_tests->new( # test that views are marked as such isa_ok $schema->resultset($monikers->{pg_loader_test11})->result_source, 'DBIx::Class::ResultSource::View', 'views have table_class set correctly'; + + is_deeply + { $schema->source($monikers->{pg_loader_test12})->unique_constraints }, + { pg_loader_test12_value => ['value'] }, + 'unique indexes are dumped correctly'; }, }, -); - -if( !$dsn || !$user ) { - $tester->skip_tests('You need to set the DBICTEST_PG_DSN, _USER, and _PASS environment variables'); -} -else { - $tester->run_tests(); -} +)->run_tests(); END { rmtree EXTRA_DUMP_DIR unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP};