Commit | Line | Data |
49aca798 |
1 | #!/usr/bin/env perl |
5ed74c87 |
2 | |
3 | use FindBin qw/$Bin/; |
4 | BEGIN { do "$FindBin::Bin/../script/env" or die $@ } |
5 | |
49aca798 |
6 | use strict; |
7 | use warnings; |
8 | use Test::More; |
9 | use HTTP::Request::Common; |
49aca798 |
10 | use JSON::Any; |
11 | |
5ed74c87 |
12 | |
49aca798 |
13 | BEGIN { |
14 | $ENV{GITALIST_CONFIG} = $Bin; |
15 | $ENV{GITALIST_REPO_DIR} = ''; |
16 | use_ok 'Catalyst::Test', 'Gitalist'; |
17 | } |
18 | |
19 | my $j = JSON::Any->new; |
20 | |
5ed74c87 |
21 | my $res = request(GET 'http://localhost/repo1', 'Content-Type' => 'application/json'); |
49aca798 |
22 | is $res->code, 200; |
23 | my $data = $j->decode($res->content); |
24 | is ref($data), 'HASH'; |
5ed74c87 |
25 | delete $data->{owner} |
26 | if $data && exists $data->{owner}; |
49aca798 |
27 | is_deeply $data, { |
49aca798 |
28 | 'is_bare' => 1, |
29 | '__CLASS__' => 'Gitalist::Git::Repository', |
30 | 'last_change' => '2009-11-12T19:00:34Z', |
49aca798 |
31 | 'name' => 'repo1', |
32 | 'description' => 'some test repository' |
33 | }; |
34 | |
2057d9bd |
35 | $res = request(GET 'http://localhost/repo1/3f7567c7bdf7e7ebf410926493b92d398333116e/commit', 'Content-Type' => 'application/json'); |
36 | is $res->code, 200; |
37 | $data = $j->decode($res->content); |
38 | is ref($data), 'HASH'; |
39 | delete $data->{repository}{owner} |
40 | if $data && exists $data->{repository}{owner}; |
41 | is_deeply $data, { |
42 | 'repository' => { |
43 | 'is_bare' => 1, |
44 | '__CLASS__' => 'Gitalist::Git::Repository', |
45 | 'last_change' => '2009-11-12T19:00:34Z', |
46 | 'name' => 'repo1', |
47 | 'description' => 'some test repository' |
48 | }, |
49 | '__CLASS__' => 'Gitalist::Git::Object::Commit', |
50 | 'sha1' => '3f7567c7bdf7e7ebf410926493b92d398333116e', |
51 | 'mode' => 0, |
52 | 'type' => 'commit', |
53 | 'modestr' => '----------', |
54 | 'size' => '218' |
55 | }; |
56 | |
49aca798 |
57 | done_testing; |
58 | |
59 | |