use test data for Perls probe
[scpubgit/System-Introspector.git] / t / repositories-git.t
CommitLineData
2ed8dcd3 1use strictures 1;
2use Test::More;
3use File::Temp qw( tempdir );
4
afd7c030 5use System::Introspector::Probe::Repositories::Git;
2ed8dcd3 6
7plan skip_all => q{Tests require a git executable}
8 unless `which git`;
9
10my $dir = tempdir(CLEANUP => 1);
11
12no warnings 'redefine';
afd7c030 13*System::Introspector::Probe::Repositories::Git::_open_locate_git_config_pipe = sub {
2ed8dcd3 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
afd7c030 21my $probe = System::Introspector::Probe::Repositories::Git->new(
2ed8dcd3 22 root => "$dir",
23);
24
dff38b1c 25my $result = $probe->gather;
26ok $result, 'received data';
27my $data = $result->{git};
28ok $data, 'received git data';
2ed8dcd3 29is scalar(keys %$data), 1, 'found single git repository';
30
31my $wc = $data->{ $dir };
32ok $wc, 'our temp repository exists in the data';
33ok scalar(keys %{$wc->{config}||{}}), 'received config values';
34
35done_testing;