From a7fee58aade5c03acfe0632525991beb5809e30a Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Wed, 24 Dec 2014 18:06:22 -0600 Subject: [PATCH] More explicit explanations --- t/Test/Qpsmtpd.pm | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/t/Test/Qpsmtpd.pm b/t/Test/Qpsmtpd.pm index 8a1958e..9ec569d 100644 --- a/t/Test/Qpsmtpd.pm +++ b/t/Test/Qpsmtpd.pm @@ -119,8 +119,22 @@ sub run_plugin_tests { } sub fake_hook { - # Used to test core code against different potential plugins - # it will interact with + ########################################################################### + # Inserts a given subroutine into the beginning of the set of hooks already + # in place. Used to test code against different potential plugins it will + # interact with. For example, to test behavior against various results of + # the data_post hook: + # + # $self->fake_hook('data_post',sub { return DECLINED }; + # ok(...); + # $self->fake_hook('data_post',sub { return DENYSOFT }; + # ok(...); + # $self->fake_hook('data_post',sub { return DENY }; + # ok(...); + # $self->fake_hook('data_post',sub { return DENY_DISCONNECT }; + # ok(...); + # $self->unfake_hook('data_post'); + ########################################################################### my ( $self, $hook, $sub ) = @_; unshift @{ $self->hooks->{$hook} ||= [] }, { @@ -138,7 +152,18 @@ sub unfake_hook { } sub fake_config { + #################################################################### # Used to test code against various possible configurations + # For example, to test against various possible config('me') values: + # + # $self->fake_config( me => '***invalid***' ); + # ok(...); + # $self->fake_config( me => 'valid-nonfqdn' ); + # ok(...); + # $self->fake_config( me => 'valid-fqdn.com'); + # ok(...); + # $self->unfake_config(); + #################################################################### my $self = shift; my $fake_config = {@_}; $self->fake_hook( 'config',