Commit | Line | Data |
a8a8f8f9 |
1 | use strict; |
2 | use warnings; |
3 | use FindBin qw/$Bin/; |
4 | use Test::More qw/no_plan/; |
56908878 |
5 | use Test::Exception; |
a8a8f8f9 |
6 | use Data::Dumper; |
7 | |
50394a3e |
8 | use Path::Class; |
9 | use Gitalist::Git::Project; |
10 | my $project = Gitalist::Git::Project->new( |
b5b638f7 |
11 | dir("$Bin/lib/repositories/repo1"), |
50394a3e |
12 | ); |
13 | |
a8a8f8f9 |
14 | BEGIN { use_ok 'Gitalist::Git::Object' } |
15 | |
16 | my $object = Gitalist::Git::Object->new( |
50394a3e |
17 | project => $project, |
a8a8f8f9 |
18 | sha1 => '729a7c3f6ba5453b42d16a43692205f67fb23bc1', |
19 | type => 'tree', |
20 | file => 'dir1', |
21 | mode => 16384, |
22 | ); |
23 | isa_ok($object, 'Gitalist::Git::Object'); |
50394a3e |
24 | is($object->sha1,'729a7c3f6ba5453b42d16a43692205f67fb23bc1', 'sha1 is correct'); |
25 | is($object->type, 'tree', 'type is correct'); |
26 | is($object->file, 'dir1', 'file is correct'); |
a8a8f8f9 |
27 | is($object->mode, 16384, 'mode is correct'); |
28 | is($object->modestr, 'd---------', "modestr is correct" ); |
483b98b7 |
29 | is($object->size, 33, "size is correct"); |
a8a8f8f9 |
30 | |
54368e9d |
31 | # Create object from sha1. |
50394a3e |
32 | my $obj2 = Gitalist::Git::Object->new( |
33 | project => $project, |
34 | sha1 => '5716ca5987cbf97d6bb54920bea6adde242d87e6', |
50394a3e |
35 | ); |
36 | isa_ok($obj2, 'Gitalist::Git::Object'); |
37 | is($obj2->sha1,'5716ca5987cbf97d6bb54920bea6adde242d87e6', 'sha1 is correct'); |
38 | is($obj2->type, 'blob', 'type is correct'); |
54368e9d |
39 | is($obj2->mode, 0, 'mode is correct'); |
40 | is($obj2->modestr, '?---------', "modestr is correct" ); |
56908878 |
41 | is($obj2->content, "bar\n", 'obj2 contents is correct'); |
483b98b7 |
42 | is($obj2->size, 4, "size is correct"); |
56908878 |
43 | dies_ok { |
44 | print $obj2->tree_sha1; |
45 | } 'tree_sha1 on a blob is an exception'; |
46 | dies_ok { |
47 | print $obj2->comment; |
48 | } 'comment is an empty string'; |