From: Alexander Hartmaier Date: Tue, 22 Mar 2011 09:45:30 +0000 (+0100) Subject: added test for action that returns an error X-Git-Tag: 2.003002~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=commitdiff_plain;h=68e022911bf388167a3c92aa392e77dd46578cda;hp=28eb7216907fc0c29f9fa58d88b24fd80e2d21d0 added test for action that returns an error --- diff --git a/t/lib/RestTest/Controller/API/REST/Artist.pm b/t/lib/RestTest/Controller/API/REST/Artist.pm index 3dad378..d2ceada 100644 --- a/t/lib/RestTest/Controller/API/REST/Artist.pm +++ b/t/lib/RestTest/Controller/API/REST/Artist.pm @@ -12,4 +12,10 @@ __PACKAGE__->config prefetch_allows => [[qw/ cds /],{ 'cds' => 'tracks'}], ); +sub action_with_error : Chained('objects_no_id') PathPart('action_with_error') Args(0) { + my ( $self, $c ) = @_; + + $c->res->status(404); +} + 1; diff --git a/t/rest/item.t b/t/rest/item.t index 3b075aa..dbc5e60 100644 --- a/t/rest/item.t +++ b/t/rest/item.t @@ -70,4 +70,17 @@ my $track_view_url = "$base/api/rest/track/"; ); } +{ + my $req = + GET( $artist_view_url . 'action_with_error', undef, 'Accept' => 'application/json' ); + $mech->request($req); + cmp_ok( $mech->status, '==', 404, 'action returned error 404' ); + my $response = $json->decode( $mech->content ); + is_deeply( + $response, + { success => 'false' }, + 'correct data returned' + ); +} + done_testing();