From 0d5ec185a8615f56d2ef38e2d48dadb111e03ac9 Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Thu, 11 Dec 2014 15:33:34 -0600 Subject: [PATCH] Make fake_config() available to all plugin tests --- t/Test/Qpsmtpd/Plugin.pm | 23 +++++++++++++++++++++++ t/plugin_tests/content_log | 23 ----------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/t/Test/Qpsmtpd/Plugin.pm b/t/Test/Qpsmtpd/Plugin.pm index 0aedb78..6693824 100644 --- a/t/Test/Qpsmtpd/Plugin.pm +++ b/t/Test/Qpsmtpd/Plugin.pm @@ -84,4 +84,27 @@ sub validate_password { return $deny, "$file - wrong password"; } +sub fake_config { + my $self = shift; + my $fake_config = {@_}; + $self->qp->hooks->{config} = [ + { + name => '___FakeHook___', + code => sub { + my ( $self, $txn, $conf ) = @_; + return DECLINED if ! exists $fake_config->{$conf}; + return OK, $fake_config->{$conf}; + }, + }, + ]; +} + +sub unfake_config { + my ( $self ) = @_; + $self->qp->hooks->{config} = [ + grep { $_->{name} ne '___FakeHook___' } + @{ $self->qp->hooks->{config} || [] } + ]; +} + 1; diff --git a/t/plugin_tests/content_log b/t/plugin_tests/content_log index af1b26c..c2aba0c 100644 --- a/t/plugin_tests/content_log +++ b/t/plugin_tests/content_log @@ -75,29 +75,6 @@ sub test_content_log_enabled { $self->unfake_config; } -sub fake_config { - my $self = shift; - my $fake_config = {@_}; - $self->qp->hooks->{config} = [ - { - name => '___FakeHook___', - code => sub { - my ( $self, $txn, $conf ) = @_; - return DECLINED if ! exists $fake_config->{$conf}; - return OK, $fake_config->{$conf}; - }, - }, - ]; -} - -sub unfake_config { - my ( $self ) = @_; - $self->qp->hooks->{config} = [ - grep { $_->{name} ne '___FakeHook___' } - @{ $self->qp->hooks->{config} || [] } - ]; -} - sub test_exclude { my ( $self ) = @_; ok( ! $self->exclude, 'exclude() default method returns false' );