From: Robert 'phaylon' Sedlacek Date: Tue, 8 May 2012 18:25:50 +0000 (+0000) Subject: Repositories::Git probe tests X-Git-Tag: v0.001_001~121 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ed8dcd3dca5d676454c52b38a6bb9c0f5ac6078;p=scpubgit%2FSystem-Introspector.git Repositories::Git probe tests --- diff --git a/t/repositories-git.t b/t/repositories-git.t new file mode 100644 index 0000000..48521ca --- /dev/null +++ b/t/repositories-git.t @@ -0,0 +1,32 @@ +use strictures 1; +use Test::More; +use File::Temp qw( tempdir ); + +use System::Introspector::Repositories::Git; + +plan skip_all => q{Tests require a git executable} + unless `which git`; + +my $dir = tempdir(CLEANUP => 1); + +no warnings 'redefine'; +*System::Introspector::Repositories::Git::_open_locate_git_config_pipe = sub { + my $output = "$dir/.git/config\n"; + open my $fh, '<', \$output; + return $fh; +}; + +system("GIT_DIR=$dir/.git git init > /dev/null"); + +my $probe = System::Introspector::Repositories::Git->new( + root => "$dir", +); + +my $data = $probe->gather; +is scalar(keys %$data), 1, 'found single git repository'; + +my $wc = $data->{ $dir }; +ok $wc, 'our temp repository exists in the data'; +ok scalar(keys %{$wc->{config}||{}}), 'received config values'; + +done_testing;