use Test::Exception;
use Try::Tiny;
use File::Path 'rmtree';
+use DBIx::Class::Optional::Dependencies;
use DBIx::Class::Schema::Loader 'make_schema_at';
+use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/;
use namespace::clean;
use DBI ();
my $user = $ENV{DBICTEST_SYBASE_USER} || '';
my $password = $ENV{DBICTEST_SYBASE_PASS} || '';
+BEGIN { $ENV{DBIC_SYBASE_FREETDS_NOWARN} = 1 }
+
my ($schema, $databases_created); # for cleanup in END for extra tests
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]");
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,
{
naming => 'current',
db_schema => $db_schema,
- moniker_parts => [qw/database name/],
dump_directory => EXTRA_DUMP_DIR,
quiet => 1,
},
[ $dsn, $user, $password ],
);
+ SybaseMultiSchema->storage->disconnect;
+
diag join "\n", @warns if @warns;
is @warns, 0;
} 'connected test schema';
lives_and {
- ok $rsrc = $test_schema->source('DbicslTest1SybaseLoaderTest4');
+ ok $rsrc = $test_schema->source('SybaseLoaderTest4');
} 'got source for table in database one';
is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
'column in database one';
lives_and {
- ok $rs = $test_schema->resultset('DbicslTest1SybaseLoaderTest4');
+ ok $rs = $test_schema->resultset('SybaseLoaderTest4');
} 'got resultset for table in database one';
lives_and {
'correct unique constraint in database one');
lives_and {
- ok $rsrc = $test_schema->source('DbicslTest2SybaseLoaderTest6');
+ ok $rsrc = $test_schema->source('SybaseLoaderTest6');
} 'got source for table in database two';
is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
'column in database two introspected correctly';
lives_and {
- ok $rs = $test_schema->resultset('DbicslTest2SybaseLoaderTest6');
+ ok $rs = $test_schema->resultset('SybaseLoaderTest6');
} 'got resultset for table in database two';
lives_and {
'relationship in database two';
lives_and {
- ok $rsrc = $test_schema->source('DbicslTest2SybaseLoaderTest7');
+ ok $rsrc = $test_schema->source('SybaseLoaderTest7');
} 'got source for table in database two';
%uniqs = try { $rsrc->unique_constraints };
'correct unique constraint in database two');
lives_and {
- ok $test_schema->source('DbicslTest2SybaseLoaderTest6')
+ ok $test_schema->source('SybaseLoaderTest6')
->has_relationship('sybase_loader_test4');
} 'cross-database relationship in multi database schema';
lives_and {
- ok $test_schema->source('DbicslTest1SybaseLoaderTest4')
+ ok $test_schema->source('SybaseLoaderTest4')
->has_relationship('sybase_loader_test6s');
} 'cross-database relationship in multi database schema';
lives_and {
- ok $test_schema->source('DbicslTest1SybaseLoaderTest8')
+ ok $test_schema->source('SybaseLoaderTest8')
->has_relationship('sybase_loader_test7');
} 'cross-database relationship in multi database schema';
lives_and {
- ok $test_schema->source('DbicslTest2SybaseLoaderTest7')
+ ok $test_schema->source('SybaseLoaderTest7')
->has_relationship('sybase_loader_test8s');
} 'cross-database relationship in multi database schema';
}
if( !$dsn || !$user ) {
$tester->skip_tests('You need to set the DBICTEST_SYBASE_DSN, _USER, and _PASS environment variables');
}
+elsif (!DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_ase')) {
+ $tester->skip_tests('You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_ase'));
+}
else {
$tester->run_tests();
}
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");
}