Commit | Line | Data |
b112c9f3 |
1 | use strictures 1; |
2 | use Test::More; |
3 | use FindBin; |
4 | |
afd7c030 |
5 | use System::Introspector::Probe::LibDirs::Perl; |
b112c9f3 |
6 | |
7 | my $dir = "$FindBin::Bin/data/libdir/perl"; |
8 | |
9 | no warnings 'redefine'; |
afd7c030 |
10 | *System::Introspector::Probe::LibDirs::Perl::_open_locate_libdirs_pipe = sub { |
b112c9f3 |
11 | my $output = "$dir/lib/perl5\n"; |
12 | open my $fh, '<', \$output; |
13 | return $fh; |
14 | }; |
15 | |
afd7c030 |
16 | my $probe = System::Introspector::Probe::LibDirs::Perl->new( |
b112c9f3 |
17 | root => $dir, |
18 | ); |
19 | my $data = $probe->gather; |
20 | |
ff854047 |
21 | my $sha = delete $data |
22 | ->{libdirs_perl}{"$dir/lib/perl5"}{modules}{Foo}[0]{sha256_hex}; |
b112c9f3 |
23 | ok $sha, 'contains SHA fingerprint'; |
24 | |
ff854047 |
25 | my $size = delete $data |
26 | ->{libdirs_perl}{"$dir/lib/perl5"}{modules}{Foo}[0]{size}; |
b112c9f3 |
27 | ok $size, 'contains file size'; |
28 | |
29 | is_deeply $data, { |
ff854047 |
30 | libdirs_perl => { |
31 | "$dir/lib/perl5" => { |
32 | modules => { |
33 | Foo => [ |
34 | { file => "$dir/lib/perl5/Foo.pm", version => 0.001 }, |
35 | ], |
36 | }, |
37 | }, |
b112c9f3 |
38 | }, |
39 | }, 'package found'; |
40 | |
41 | done_testing; |