Repositories::Git probe tests
Robert 'phaylon' Sedlacek [Tue, 8 May 2012 18:25:50 +0000 (18:25 +0000)]
t/repositories-git.t [new file with mode: 0644]

diff --git a/t/repositories-git.t b/t/repositories-git.t
new file mode 100644 (file)
index 0000000..48521ca
--- /dev/null
@@ -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;