Skip to content

Commit a2bb17b

Browse files
committed
00_setup.t - added package indexing
1 parent 7da97bc commit a2bb17b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

bin/package.pl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313
>;
1414

1515
# args
16-
my $cleanup;
17-
GetOptions( "cleanup" => \$cleanup );
16+
my ( $cleanup, $mode, $package_file );
17+
GetOptions(
18+
"cleanup" => \$cleanup,
19+
"mode=s" => \$mode,
20+
"package_file=s" => \$package_file,
21+
);
22+
# TODO: find a better way
23+
$mode eq 'test' and Log::Log4perl::init('log4perl_test.conf');
1824

1925
# setup
20-
my $es = MetaCPAN::ES->new( type => "package" );
26+
my $es = MetaCPAN::ES->new( index => "package", ( $mode ? ( mode => $mode ) : () ) );
2127
my $bulk = $es->bulk();
2228

2329
my %seen;
@@ -27,7 +33,7 @@
2733

2834
# read the rest of the file line-by-line (too big to slurp)
2935

30-
my $fh_packages = read_02packages_fh( log_meta => 1 );
36+
my $fh_packages = read_02packages_fh( log_meta => 1, ( $package_file ? (file => $package_file) : () ) );
3137
while ( my $line = <$fh_packages> ) {
3238
next unless $line;
3339
chomp($line);

t/00_setup.t

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ my $modules = $test_dir->child('modules');
2525

2626
my @files = qw<
2727
00whois.xml
28-
02packages.details.txt
28+
02packages.details.txt.gz
2929
06perms.txt
3030
>;
3131

3232
subtest 'Check Files' => sub {
3333
ok( $authors->child('00whois.xml'), "Found 00whois.xml" );
34-
ok( $modules->child('02packages.details.txt'), "Found 02packages.details.txt" );
34+
ok( $modules->child('02packages.details.txt.gz'), "Found 02packages.details.txt.gz" );
3535
ok( $modules->child('06perms.txt'), "Found 06perms.txt" );
3636
};
3737

@@ -82,6 +82,16 @@ subtest 'Author Indexing' => sub {
8282
ok( $es_author->exists( index => 'author', id => 'OALDERS' ), "Found author OALDERS" );
8383
};
8484

85+
# run the package indexing script in test mode
86+
my $package_script = $bin->child('package.pl');
87+
my $package_file = $modules->child('02packages.details.txt.gz');
88+
`perl $package_script -package_file $package_file --mode test`;
89+
90+
subtest 'Package Indexing' => sub {
91+
my $es_package = MetaCPAN::ES->new( index => 'package', mode => 'test' );
92+
ok( $es_package->exists( index => 'package', id => 'LWP' ), "Found package LWP" );
93+
};
94+
8595
# run the permission indexing script in test mode
8696
my $perms_script = $bin->child('permission.pl');
8797
my $perms_file = $modules->child('06perms.txt');

0 commit comments

Comments
 (0)