Tests for Qpsmtpd::Address::config()

Tests for the new Qpsmtpd::Address::config() which should call hook_user_config plugins
This commit is contained in:
Jared Johnson 2014-09-12 02:42:08 -05:00
parent 8d032d8b50
commit eb482aad0a

View File

@ -6,8 +6,24 @@ use Test::More;
use lib 'lib';
BEGIN {
use_ok('Qpsmtpd::Address');
BEGIN { use_ok('Qpsmtpd::Constants'); }
use_ok('Qpsmtpd::Address');
use lib 't';
use_ok('Test::Qpsmtpd');
__config();
sub __config {
ok( my ($qp,$cxn) = Test::Qpsmtpd->new_conn(), "get new connection" );
ok( $qp->command('HELO test') );
ok( $qp->command('MAIL FROM:<test@example.com>') );
my $sender = $qp->transaction->sender;
$qp->hooks->{user_config} = [];
is( $sender->config('test config'), undef, 'no user_config plugins exist' );
$qp->hooks->{user_config} = [{ name => 'test hook', code => sub { return DECLINED } }];
is( $sender->config('test config'), undef, 'no user_config plugins return OK' );
$qp->hooks->{user_config} = [{ name => 'test hook', code => sub { return OK, 'test data' } }];
is( $sender->config('test config'), 'test data', 'user_config plugins return a value' );
}
__new();