added lines_from_command util
[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::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::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::Repositories::Git->new(
22     root => "$dir",
23 );
24
25 my $data = $probe->gather;
26 is scalar(keys %$data), 1, 'found single git repository';
27
28 my $wc = $data->{ $dir };
29 ok $wc, 'our temp repository exists in the data';
30 ok scalar(keys %{$wc->{config}||{}}), 'received config values';
31
32 done_testing;