Skip to content

Commit 1741f3d

Browse files
committed
Fix BackPAN::Index for testing.
It was using the default location for the index and the cache. We just got lucky none of the distributions we use for testing changed. Now it uses the index in t/ and puts its cache there.
1 parent af7a4cd commit 1741f3d

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ MYMETA.*
1515
*.o
1616
gitpan-build
1717
t/gitpan
18+
t/caches/

.gitpan

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,9 @@ committer_email: schwern+gitpan-test@pobox.com
788788
overlays:
789789
test:
790790
backpan_always_update: 0
791+
backpan_cache_dir: t/caches/backpan/
791792
backpan_cache_ttl: 604800
793+
backpan_index_url: file:t/backpan/backpan-index.gz
792794
backpan_url: file:t/backpan/
793795

794796
github_owner: gitpan-test

lib/Gitpan/Config.pm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ haz backpan_url =>
99
isa => URI,
1010
default => 'http://gitpan.integra.net/backpan';
1111

12+
haz backpan_index_url =>
13+
is => 'ro',
14+
isa => URI,
15+
default => 'http://gitpan.integra.net/backpan-index.gz';
16+
17+
haz backpan_cache_dir =>
18+
is => 'ro',
19+
isa => Maybe[AbsPath];
20+
1221
haz backpan_cache_ttl =>
1322
is => 'ro',
1423
isa => Int,

lib/Gitpan/Role/HasBackpanIndex.pm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ method _build_index {
4141
push @opts, (normalize_releases => $config->backpan_normalize_releases)
4242
if keys %{$config->backpan_normalize_releases};
4343

44+
push @opts, (cache_dir => $config->backpan_cache_dir.'')
45+
if defined $config->backpan_cache_dir;
46+
47+
push @opts, (backpan_index_url => $config->backpan_index_url)
48+
if defined $config->backpan_index_url;
49+
4450
return BackPAN::Index->new(
4551
cache_ttl => $self->config->backpan_cache_ttl,
4652
releases_only_from_authors => 1,

t/HasBackpanIndex.t

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,16 @@ note "not shared across forks"; {
4242
Test::More->builder->current_test( Test::More->builder->current_test + $child->read );
4343
}
4444

45+
note "test config"; {
46+
my $obj = Some::Class->new;
47+
my $bp = $obj->backpan_index;
48+
49+
ok("t"->path->subsumes($bp->cache_dir->path),
50+
"backpan cache is in the t/ directory")
51+
or diag $bp->cache_dir;
52+
53+
is $bp->backpan_index_url->scheme, "file";
54+
is $bp->backpan_index_url->path, "t/backpan/backpan-index.gz";
55+
}
56+
4557
done_testing;

0 commit comments

Comments
 (0)