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