made remote timeout configurable by env
[scpubgit/System-Introspector.git] / t / repositories-git.t
1 use strictures 1;
2 use Test::More;
3 use File::Temp qw( tempdir );
4
5 use System::Introspector::Probe::Repositories::Git;
6
7 plan skip_all => q{Tests require a git executable}
8     unless `which git`;
9
10 my $dir = tempdir(CLEANUP => 1);
11
12 no warnings 'redefine';
13 *System::Introspector::Probe::Repositories::Git::_open_locate_git_config_pipe = sub {
14     my $output = "$dir/.git/config\n";
15     open my $fh, '<', \$output;
16     return $fh;
17 };
18
19 system("GIT_DIR=$dir/.git git init > /dev/null");
20
21 my $probe = System::Introspector::Probe::Repositories::Git->new(
22     root => "$dir",
23 );
24
25 my $result = $probe->gather;
26 ok $result, 'received data';
27 my $data = $result->{git};
28 ok $data, 'received git data';
29 is scalar(keys %$data), 1, 'found single git repository';
30
31 my $wc = $data->{ $dir };
32 ok $wc, 'our temp repository exists in the data';
33 ok scalar(keys %{$wc->{config}||{}}), 'received config values';
34
35 done_testing;