Fixed failing Content-Type tests.
[catagits/Gitalist.git] / t / json_view.t
1 #!/usr/bin/env perl
2
3 use FindBin qw/$Bin/;
4 BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
5
6 use strict;
7 use warnings;
8 use Test::More;
9 use HTTP::Request::Common;
10 use JSON::Any;
11
12
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
21 my $res = request(GET 'http://localhost/repo1', 'Content-Type' => 'application/json');
22 is $res->code, 200;
23 my $data = $j->decode($res->content);
24 is ref($data), 'HASH';
25 delete $data->{owner}
26   if $data && exists $data->{owner};
27 is_deeply $data, {
28           'is_bare' => 1,
29           '__CLASS__' => 'Gitalist::Git::Repository',
30           'last_change' => '2009-11-12T19:00:34Z',
31           'name' => 'repo1',
32           'description' => 'some test repository'
33         };
34
35 done_testing;
36
37