Improve POD test and make it author-only
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_03pg_common.t
index 1da712b..0225b33 100644 (file)
@@ -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,
@@ -249,6 +252,8 @@ my $tester = dbixcsl_common_tests->new(
             q{
                 create table pg_loader_test12 (
                     id integer not null,
+                    value integer,
+                    active boolean,
                     name text
                 )
             },
@@ -262,6 +267,16 @@ my $tester = dbixcsl_common_tests->new(
                     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',
@@ -466,18 +481,13 @@ my $tester = dbixcsl_common_tests->new(
             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 },
-                {}, 'unique indexes with expressions are not dumped';
+            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};