Install curry in Travis
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_06sybase_common.t
index afce0d0..d19b7b7 100644 (file)
@@ -1,3 +1,6 @@
+use DBIx::Class::Schema::Loader::Optional::Dependencies
+    -skip_all_without => 'test_rdbms_ase';
+
 use strict;
 use warnings;
 use Test::More;
@@ -5,6 +8,7 @@ use Test::Exception;
 use Try::Tiny;
 use File::Path 'rmtree';
 use DBIx::Class::Schema::Loader 'make_schema_at';
+use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/;
 use namespace::clean;
 use DBI ();
 
@@ -23,7 +27,7 @@ BEGIN { $ENV{DBIC_SYBASE_FREETDS_NOWARN} = 1 }
 
 my ($schema, $databases_created); # for cleanup in END for extra tests
 
-my $tester = dbixcsl_common_tests->new(
+dbixcsl_common_tests->new(
     vendor      => 'sybase',
     auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY',
     default_function     => 'getdate()',
@@ -131,11 +135,9 @@ my $tester = dbixcsl_common_tests->new(
                 };
 
                 try {
-                    my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
-                    local $SIG{__WARN__} = sub {
-                        $warn_handler->(@_)
-                            unless $_[0] =~ /^Password correctly set\.$|^Account unlocked\.$|^New login created\.$|^New user added\.$/;
-                    };
+                    local $SIG{__WARN__} = sigwarn_silencer(
+                        qr/^Password correctly set\.$|^Account unlocked\.$|^New login created\.$|^New user added\.$/
+                    );
 
                     $dbh->do("sp_addlogin dbicsl_user1, dbicsl, [dbicsl_test1]");
                     $dbh->do("sp_addlogin dbicsl_user2, dbicsl, [dbicsl_test2]");
@@ -158,11 +160,9 @@ my $tester = dbixcsl_common_tests->new(
 
                 my ($dbh1, $dbh2);
                 {
-                    my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
-                    local $SIG{__WARN__} = sub {
-                        $warn_handler->(@_) unless $_[0] =~ /can't change context/;
-                    };
-
+                    local $SIG{__WARN__} = sigwarn_silencer(
+                        qr/can't change context/
+                    );
                     $dbh1 = DBI->connect($dsn, 'dbicsl_user1', 'dbicsl', {
                         RaiseError => 1,
                         PrintError => 0,
@@ -261,6 +261,8 @@ EOF
                                 [ $dsn, $user, $password ],
                             );
 
+                            SybaseMultiSchema->storage->disconnect;
+
                             diag join "\n", @warns if @warns;
 
                             is @warns, 0;
@@ -390,14 +392,7 @@ EOF
             }
         },
     },
-);
-
-if( !$dsn || !$user ) {
-    $tester->skip_tests('You need to set the DBICTEST_SYBASE_DSN, _USER, and _PASS environment variables');
-}
-else {
-    $tester->run_tests();
-}
+)->run_tests();
 
 END {
     if (not $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}) {
@@ -444,11 +439,9 @@ END {
 
             foreach my $login (qw/dbicsl_user1 dbicsl_user2/) {
                 try {
-                    my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
-                    local $SIG{__WARN__} = sub {
-                        $warn_handler->(@_)
-                            unless $_[0] =~ /^Account locked\.$|^Login dropped\.$/;
-                    };
+                    local $SIG{__WARN__} = sigwarn_silencer(
+                        qr/^Account locked\.$|^Login dropped\.$/
+                    );
 
                     $dbh->do("sp_droplogin $login");
                 }