Stop Project->diff() blowing up when no parent is specified, and commit
[catagits/Gitalist.git] / t / 02git_object.t
CommitLineData
a8a8f8f9 1use strict;
2use warnings;
3use FindBin qw/$Bin/;
4use Test::More qw/no_plan/;
5
6use Data::Dumper;
7
50394a3e 8use Path::Class;
9use Gitalist::Git::Project;
10my $project = Gitalist::Git::Project->new(
483b98b7 11 name => 'repo1',
58251520 12 path => dir("$Bin/lib/repositories/repo1"),
50394a3e 13);
14
a8a8f8f9 15BEGIN { use_ok 'Gitalist::Git::Object' }
16
17my $object = Gitalist::Git::Object->new(
50394a3e 18 project => $project,
a8a8f8f9 19 sha1 => '729a7c3f6ba5453b42d16a43692205f67fb23bc1',
20 type => 'tree',
21 file => 'dir1',
22 mode => 16384,
23);
24isa_ok($object, 'Gitalist::Git::Object');
50394a3e 25is($object->sha1,'729a7c3f6ba5453b42d16a43692205f67fb23bc1', 'sha1 is correct');
26is($object->type, 'tree', 'type is correct');
27is($object->file, 'dir1', 'file is correct');
a8a8f8f9 28is($object->mode, 16384, 'mode is correct');
29is($object->modestr, 'd---------', "modestr is correct" );
483b98b7 30is($object->size, 33, "size is correct");
a8a8f8f9 31
54368e9d 32# Create object from sha1.
50394a3e 33my $obj2 = Gitalist::Git::Object->new(
34 project => $project,
35 sha1 => '5716ca5987cbf97d6bb54920bea6adde242d87e6',
50394a3e 36);
37isa_ok($obj2, 'Gitalist::Git::Object');
38is($obj2->sha1,'5716ca5987cbf97d6bb54920bea6adde242d87e6', 'sha1 is correct');
39is($obj2->type, 'blob', 'type is correct');
54368e9d 40is($obj2->mode, 0, 'mode is correct');
41is($obj2->modestr, '?---------', "modestr is correct" );
50394a3e 42is($obj2->contents, "bar\n", 'obj2 contents is correct');
483b98b7 43is($obj2->size, 4, "size is correct");