X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fjson_view.t;h=2b682671c0e33b15dacf38ab83724de04ca0e7cf;hb=09717a40ef5a5d43158701e91ead9ac7934880db;hp=026479ddc328ac154b523b8364951a6d2a865461;hpb=49aca7983a7084e60f0aa1165f122c93d9282ddb;p=catagits%2FGitalist.git diff --git a/t/json_view.t b/t/json_view.t index 026479d..2b68267 100644 --- a/t/json_view.t +++ b/t/json_view.t @@ -1,10 +1,18 @@ #!/usr/bin/env perl + +use FindBin qw/$Bin/; +BEGIN { + my $env = "$FindBin::Bin/../script/env"; + if (-r $env) { + do $env or die $@; + } +} + use strict; use warnings; use Test::More; use HTTP::Request::Common; -use FindBin qw/$Bin/; -use JSON::Any; +use JSON::XS qw/decode_json encode_json/; BEGIN { $ENV{GITALIST_CONFIG} = $Bin; @@ -12,25 +20,16 @@ BEGIN { use_ok 'Catalyst::Test', 'Gitalist'; } -my $j = JSON::Any->new; - -my $res = request(GET 'http://localhost/summary?p=repo1', 'Content-Type' => 'application/json'); +my $res = request(GET 'http://localhost/repo1', 'Content-Type' => 'application/json'); is $res->code, 200; -my $data = $j->decode($res->content); +my $data = decode_json $res->content; is ref($data), 'HASH'; +delete $data->{owner} + if $data && exists $data->{owner}; is_deeply $data, { - 'owner' => 'Tomas Doran', 'is_bare' => 1, '__CLASS__' => 'Gitalist::Git::Repository', - 'last_change' => '2009-11-12T19:00:34Z', - 'references' => { - '0710a7c8ee11c73e8098d08f9384c2a839c65e4e' => [ - 'heads/branch1' - ], - '36c6c6708b8360d7023e8a1649c45bcf9b3bd818' => [ - 'heads/master' - ] - }, + 'last_change' => '2011-06-05T23:00:44Z', 'name' => 'repo1', 'description' => 'some test repository' };