auth_vpopmail_sql test, eval 'use DBI' before testing

This commit is contained in:
Matt Simerson 2012-05-21 18:06:22 -04:00
parent 1a1dcc3e53
commit 55b5f34365
2 changed files with 10 additions and 5 deletions

View File

@ -23,7 +23,7 @@ sub test_auth_vpopmail {
if ( ! $self->test_vpopmail_module ) { if ( ! $self->test_vpopmail_module ) {
warn "vpopmail plugin not configured\n"; warn "vpopmail plugin not configured\n";
foreach ( 0..2) { ok( 1, "test_auth_vpopmail, skipped") }; foreach ( 0..2) { ok( 1, "skipped") };
return; return;
}; };

View File

@ -6,6 +6,11 @@ use warnings;
sub register_tests { sub register_tests {
my $self = shift; my $self = shift;
eval 'use DBI';
if ( $@ ) {
warn "skipping auth_vpopmail_sql tests, is DBI installed?\n";
return;
};
$self->register_test("auth_vpopmail_sql", 3); $self->register_test("auth_vpopmail_sql", 3);
} }
@ -15,7 +20,7 @@ sub auth_vpopmail_sql {
my $dbh = $self->get_db_handle() or do { my $dbh = $self->get_db_handle() or do {
foreach ( 0..2 ) { foreach ( 0..2 ) {
ok( 1, "auth_vpopmail_sql, skipped (no DB)" ); ok( 1, "skipped (no DB)" );
}; };
return; return;
}; };
@ -24,11 +29,11 @@ sub auth_vpopmail_sql {
my $vuser = $self->get_vpopmail_user( $dbh, 'postmaster@example.com' ); my $vuser = $self->get_vpopmail_user( $dbh, 'postmaster@example.com' );
if ( ! $vuser || ! $vuser->{pw_passwd} ) { if ( ! $vuser || ! $vuser->{pw_passwd} ) {
foreach ( 0..1 ) { foreach ( 0..1 ) {
ok( 1, "auth_vpopmail_sql, no example.com domain" ); ok( 1, "no example.com domain" );
}; };
return; return;
}; };
ok( ref $vuser, "auth_vpopmail_sql, found example.com domain" ); ok( ref $vuser, "found example.com domain" );
ok( $self->auth_vmysql( ok( $self->auth_vmysql(
$self->qp->transaction, $self->qp->transaction,
@ -38,6 +43,6 @@ sub auth_vpopmail_sql {
$vuser->{pw_passwd}, $vuser->{pw_passwd},
$ticket, $ticket,
), ),
"auth_vpopmail_sql, postmaster" "postmaster"
); );
} }