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