X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F02git_object.t;h=d05a54c198d2a18b7ed885501e50099debc0b9e4;hb=5e26dc93f7d8f6b3a9df80f69b3cc5f3f477f8be;hp=84ac439fd591a84ef6e238b7598021a87c1c4011;hpb=1aae440e61b68d1f703a63ead38411f5bb428062;p=catagits%2FGitalist.git diff --git a/t/02git_object.t b/t/02git_object.t index 84ac439..d05a54c 100644 --- a/t/02git_object.t +++ b/t/02git_object.t @@ -11,6 +11,7 @@ use warnings; use Test::More; use Test::Exception; use Data::Dumper; +use Test::Deep; use Path::Class; use Gitalist::Git::Repository; @@ -23,7 +24,7 @@ BEGIN { use_ok 'Gitalist::Git::Object::Blob'; use_ok 'Gitalist::Git::Object::Commit'; use_ok 'Gitalist::Git::Object::Tag'; - } +} my $object = Gitalist::Git::Object::Tree->new( repository => $repository, @@ -41,7 +42,7 @@ is($object->modestr, 'drwxr-xr-x', "modestr is correct" ); is($object->size, 33, "size is correct"); is($object,'729a7c3f6ba5453b42d16a43692205f67fb23bc1', 'stringifies correctly'); -is_deeply $object->pack, { +cmp_deeply $object->pack, { __CLASS__ => 'Gitalist::Git::Object::Tree', file => 'dir1', @@ -53,9 +54,9 @@ is_deeply $object->pack, { __CLASS__ => 'Gitalist::Git::Repository', description => 'some test repository', is_bare => 1, - last_change => '2009-11-12T19:00:34Z', + last_change => '2011-06-05T23:00:44Z', name => 'repo1', - owner => 'Dan' + owner => code(\&is_system_account_name), }, sha1 => '729a7c3f6ba5453b42d16a43692205f67fb23bc1', size => 33, @@ -81,7 +82,7 @@ dies_ok { print $obj2->comment; } 'comment is an empty string'; -is_deeply $obj2->pack, { +cmp_deeply $obj2->pack, { __CLASS__ => 'Gitalist::Git::Object::Blob', mode => 0, @@ -92,9 +93,9 @@ is_deeply $obj2->pack, { __CLASS__ => 'Gitalist::Git::Repository', description => 'some test repository', is_bare => 1, - last_change => '2009-11-12T19:00:34Z', + last_change => '2011-06-05T23:00:44Z', name => 'repo1', - owner => 'Dan' + owner => code(\&is_system_account_name), }, sha1 => '5716ca5987cbf97d6bb54920bea6adde242d87e6', size => 4, @@ -108,7 +109,7 @@ my $commit_obj = Gitalist::Git::Object::Commit->new( isa_ok($commit_obj, 'Gitalist::Git::Object::Commit', "commit object"); isa_ok($commit_obj->tree->[0], 'Gitalist::Git::Object::Tree'); -is_deeply $commit_obj->pack, { +cmp_deeply $commit_obj->pack, { __CLASS__ => 'Gitalist::Git::Object::Commit', mode => 0, @@ -119,9 +120,9 @@ is_deeply $commit_obj->pack, { __CLASS__ => 'Gitalist::Git::Repository', description => 'some test repository', is_bare => 1, - last_change => '2009-11-12T19:00:34Z', + last_change => '2011-06-05T23:00:44Z', name => 'repo1', - owner => 'Dan' + owner => code(\&is_system_account_name), }, sha1 => '3f7567c7bdf7e7ebf410926493b92d398333116e', size => 218, @@ -136,9 +137,9 @@ is_deeply $commit_obj->pack, { __CLASS__ => 'Gitalist::Git::Repository', description => 'some test repository', is_bare => 1, - last_change => '2009-11-12T19:00:34Z', + last_change => '2011-06-05T23:00:44Z', name => 'repo1', - owner => 'Dan' + owner => code(\&is_system_account_name), }, sha1 => '9062594aebb5df0de7fb92413f17a9eced196c22', size => 33, @@ -197,5 +198,23 @@ index 257cc56..5716ca5 100644 'commit_obj->get_patch can return a patchset') or warn("Contents was $contents"); } + +my $blame_this = Gitalist::Git::Object::Commit->new( + repository => $repository, + sha1 => 'd6ddf8b26be63066e01d96a0922c87cd8d6e2270', +); + +{ + local $SIG{ALRM} = sub { die "Regressions suck!" }; + alarm 1; + eval { $blame_this->blame('empty-for-a-reason', $blame_this->sha1) }; + is $@, '', "Silly infinite loop didn't manifest for an empty file."; +} + done_testing; +sub is_system_account_name { + my $name = shift; + return 0 if !$name; + return 1; +}