Permalink
Browse files

make testpause return an inspectable results obj

  • Loading branch information...
1 parent 6905d15 commit 7e06c4168f0c88a2773862245a87566851b90dc0 @rjbs rjbs committed Aug 13, 2011
Showing with 55 additions and 17 deletions.
  1. +27 −15 t/lib/PAUSE/TestPAUSE.pm
  2. +26 −0 t/lib/PAUSE/TestPAUSE/Result.pm
  3. +2 −2 t/mldistwatch.t
View
42 t/lib/PAUSE/TestPAUSE.pm
@@ -2,12 +2,16 @@ package PAUSE::TestPAUSE;
use Moose;
use MooseX::StrictConstructor;
+use autodie;
+
+use DBI;
use File::Path qw(make_path);
use File::Temp ();
use File::Copy::Recursive qw(dircopy);
use PAUSE;
use PAUSE::mldistwatch;
+use PAUSE::TestPAUSE::Result;
use namespace::autoclean;
@@ -41,29 +45,37 @@ sub test {
my $db_root = File::Spec->catdir($tmpdir, 'db');
my $dsnbase = "DBI:SQLite:dbname=$db_root";
- local $PAUSE::Config->{AUTHEN_DATA_SOURCE_NAME} = "$dsnbase/authen.sqlite";
- local $PAUSE::Config->{MOD_DATA_SOURCE_NAME} = "$dsnbase/mod.sqlite";
+ my $pid_dir = File::Spec->catdir($tmpdir, 'run');
+ mkdir $pid_dir;
$self->deploy_schemas_at($db_root);
- local $PAUSE::Config->{MLROOT} = File::Spec->catdir($ml_root);
-
- local $PAUSE::Config->{PID_DIR} = File::Spec->catdir($tmpdir, 'run');
- mkdir $PAUSE::Config->{PID_DIR};
-
- local $PAUSE::Config->{ML_MIN_FILES} = 1;
- local $PAUSE::Config->{ML_MIN_INDEX_LINES} = 1;
-
- local $PAUSE::Config->{ML_CHOWN_USER} = +(getpwuid($>))[0];
- local $PAUSE::Config->{ML_CHOWN_GROUP} = +(getgrgid($)))[0];
-
- local $PAUSE::Config->{ML_MAILER} = 'testfile';
+ my %overrides = (
+ AUTHEN_DATA_SOURCE_NAME => "$dsnbase/authen.sqlite",
+ # CHECKSUMS_SIGNING_PROGRAM => 'xyzzy',
+ MLROOT => File::Spec->catdir($ml_root),
+ ML_CHOWN_GROUP => +(getgrgid($)))[0],
+ ML_CHOWN_USER => +(getpwuid($>))[0],
+ ML_MAILER => 'testfile',
+ ML_MIN_FILES => 1,
+ ML_MIN_INDEX_LINES => 1,
+ MOD_DATA_SOURCE_NAME => "$dsnbase/mod.sqlite",
+ PID_DIR => $pid_dir,
+ );
+
+ local $PAUSE::Config = {
+ %{ $PAUSE::Config },
+ %overrides,
+ };
PAUSE::mldistwatch->new->reindex;
$code->($tmpdir) if $code;
- return $tmpdir;
+ return PAUSE::TestPAUSE::Result->new({
+ tmpdir => $tmpdir,
+ config_overrides => \%overrides,
+ });
}
1;
View
26 t/lib/PAUSE/TestPAUSE/Result.pm
@@ -0,0 +1,26 @@
+package PAUSE::TestPAUSE::Result;
+use Moose;
+use MooseX::StrictConstructor;
+
+use Path::Class;
+
+use namespace::autoclean;
+
+has tmpdir => (
+ reader => '_tmpdir_obj',
+ isa => 'Object',
+ required => 1,
+);
+
+sub tmpdir {
+ my ($self) = @_;
+ return dir($self->_tmpdir_obj);
+}
+
+has config_overrides => (
+ reader => '_config_overrides',
+ isa => 'HashRef[Str]',
+ required => 1,
+);
+
+1;
View
4 t/mldistwatch.t
@@ -9,12 +9,12 @@ use PAUSE::TestPAUSE;
use Test::More;
-my $tmpdir = PAUSE::TestPAUSE->new({
+my $result = PAUSE::TestPAUSE->new({
author_root => 'corpus/authors',
})->test;
ok(
- -e File::Spec->catfile($tmpdir, qw(cpan modules 02packages.details.txt.gz)),
+ -e $result->tmpdir->file(qw(cpan modules 02packages.details.txt.gz)),
"our indexer indexed",
);

0 comments on commit 7e06c41

Please sign in to comment.