added lines_from_command util
[scpubgit/System-Introspector.git] / t / repositories-git.t
CommitLineData
2ed8dcd3 1use strictures 1;
2use Test::More;
3use File::Temp qw( tempdir );
4
5use System::Introspector::Repositories::Git;
6
7plan skip_all => q{Tests require a git executable}
8 unless `which git`;
9
10my $dir = tempdir(CLEANUP => 1);
11
12no 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
19system("GIT_DIR=$dir/.git git init > /dev/null");
20
21my $probe = System::Introspector::Repositories::Git->new(
22 root => "$dir",
23);
24
25my $data = $probe->gather;
26is scalar(keys %$data), 1, 'found single git repository';
27
28my $wc = $data->{ $dir };
29ok $wc, 'our temp repository exists in the data';
30ok scalar(keys %{$wc->{config}||{}}), 'received config values';
31
32done_testing;