Make fake_config() available to all plugin tests

This commit is contained in:
Jared Johnson 2014-12-11 15:33:34 -06:00
parent 4f4e19ba0a
commit 0d5ec185a8
2 changed files with 23 additions and 23 deletions

View File

@ -84,4 +84,27 @@ sub validate_password {
return $deny, "$file - wrong 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; 1;

View File

@ -75,29 +75,6 @@ sub test_content_log_enabled {
$self->unfake_config; $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 { sub test_exclude {
my ( $self ) = @_; my ( $self ) = @_;
ok( ! $self->exclude, 'exclude() default method returns false' ); ok( ! $self->exclude, 'exclude() default method returns false' );