X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fjson_view.t;h=e5a436cbe9441d26e0af243b6532d00b8b6d6bf1;hb=1aae440e61b68d1f703a63ead38411f5bb428062;hp=f275d59072a30aad690d4af7056de29cf4cb2eb3;hpb=2057d9bdb7d693c8b8115b0a47fef542837cb314;p=catagits%2FGitalist.git diff --git a/t/json_view.t b/t/json_view.t index f275d59..e5a436c 100644 --- a/t/json_view.t +++ b/t/json_view.t @@ -1,14 +1,18 @@ #!/usr/bin/env perl use FindBin qw/$Bin/; -BEGIN { do "$FindBin::Bin/../script/env" or die $@ } +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 JSON::Any; - +use JSON::XS qw/decode_json encode_json/; BEGIN { $ENV{GITALIST_CONFIG} = $Bin; @@ -16,11 +20,9 @@ BEGIN { use_ok 'Catalyst::Test', 'Gitalist'; } -my $j = JSON::Any->new; - 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}; @@ -32,28 +34,6 @@ is_deeply $data, { 'description' => 'some test repository' }; -$res = request(GET 'http://localhost/repo1/3f7567c7bdf7e7ebf410926493b92d398333116e/commit', 'Content-Type' => 'application/json'); -is $res->code, 200; -$data = $j->decode($res->content); -is ref($data), 'HASH'; -delete $data->{repository}{owner} - if $data && exists $data->{repository}{owner}; -is_deeply $data, { - 'repository' => { - 'is_bare' => 1, - '__CLASS__' => 'Gitalist::Git::Repository', - 'last_change' => '2009-11-12T19:00:34Z', - 'name' => 'repo1', - 'description' => 'some test repository' - }, - '__CLASS__' => 'Gitalist::Git::Object::Commit', - 'sha1' => '3f7567c7bdf7e7ebf410926493b92d398333116e', - 'mode' => 0, - 'type' => 'commit', - 'modestr' => '----------', - 'size' => '218' -}; - done_testing;