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