diff --git a/t/qpsmtpd-address.t b/t/qpsmtpd-address.t index 94fa11c..ca056c3 100644 --- a/t/qpsmtpd-address.t +++ b/t/qpsmtpd-address.t @@ -152,13 +152,13 @@ sub __config { my @test_data = ( { pref => 'size_threshold', - result => [], + result => undef, expected => 10000, descr => 'fall back to global config when user_config is absent', }, { pref => 'test_config', - result => [], + result => undef, expected => undef, descr => 'return nothing when no user_config plugins exist', }, @@ -176,16 +176,11 @@ sub __config { }, ); for (@test_data) { - $qp->hooks->{user_config} = @{$_->{result}} - ? [ - { - name => 'test hook', - code => sub { return @{$_->{result}} } - } - ] - : undef; + $qp->fake_hook( 'user_config', sub { return @{$_->{result}} } ) + if $_->{result}; is($sender->config($_->{pref}), $_->{expected}, $_->{descr}); } + $qp->unfake_hook('user_config'); } sub __canonify { diff --git a/t/qpsmtpd.t b/t/qpsmtpd.t index 4abf17c..b2e0ba1 100644 --- a/t/qpsmtpd.t +++ b/t/qpsmtpd.t @@ -258,8 +258,8 @@ sub __config { { pref => 'size_threshold', hooks => { - user_config => [], - config => [], + user_config => undef, + config => undef, }, expected => { user => 10000, @@ -270,8 +270,8 @@ sub __config { { pref => 'timeout', hooks => { - user_config => [], - config => [], + user_config => undef, + config => undef, }, expected => { user => 1200, @@ -329,15 +329,8 @@ sub __config { }, ); for my $t (@test_data) { - for my $hook (qw( config user_config )) { - $qp->hooks->{$hook} = @{$t->{hooks}{$hook}} - ? [ - { - name => 'test hook', - code => sub { return @{$t->{hooks}{$hook}} } - } - ] - : undef; + for my $hook ( grep { $t->{hooks}{$_} } qw( config user_config ) ) { + $qp->fake_hook( $hook, sub { return @{ $t->{hooks}{$hook} } } ); } is( $qp->config($t->{pref}, $a), @@ -348,6 +341,7 @@ sub __config { $t->{expected}{global}, "Global config: $t->{descr}"); } + $qp->unfake_hook($_) for qw( config user_config ); } sub __warn_level {