Debian Codegraph @

xt/author/pod_link.t

raw
1 use Test2::Require::Module 'Test::Pod::LinkCheck::Lite';
2 use Test2::Require::EnvVar 'POD_CHECK';
3 use Test2::V0;
4 use Test::Pod::LinkCheck::Lite;
5 use Path::Tiny qw( path );
6 use HTTP::Tiny::Mech;
7 use WWW::Mechanize::Cached;
8 use CHI;
9
10 my @checks;
11
12 if(-d 'blib/script')
13 {
14 push @checks, 'blib/script';
15 }
16 elsif(-d 'bin')
17 {
18 push @checks, 'bin';
19 }
20
21 if(-d 'blib')
22 {
23 push @checks, 'blib';
24 }
25 else
26 {
27 push @checks, 'lib';
28 diag "checking lib instead of blib";
29 }
30
31 my $dir = path('~/.xor/cache');
32 $dir->mkpath;
33 $dir->chmod(0700);
34 my $ua = HTTP::Tiny::Mech->new(
35 mechua => WWW::Mechanize::Cached->new(
36 cache => CHI->new(
37 # keep cache around for 24hrs
38 expires_in => 60*60*24,
39 driver => 'File',
40 root_dir => $dir->stringify,
41 ),
42 ),
43 );
44
45 my $mock1 = mock 'Test::Pod::LinkCheck::Lite' => (
46 override => [
47 _user_agent => sub { $ua },
48 ],
49 );
50
51 # WWW::Mechanize::Cached gets confused by HEAD
52 # requests and thinks they are invalid because
53 # content-length is non-zero (as it should be)
54 my $mock2 = mock 'HTTP::Tiny::Mech' => (
55 override => [
56 head => sub { shift->get(@_) },
57 ],
58 );
59
60 Test::Pod::LinkCheck::Lite
61 ->new
62 ->all_pod_files_ok(@checks);
63
64 done_testing;