6 my $base = 'http://localhost';
12 use Test::WWW::Mechanize::Catalyst 'RestTest';
13 use HTTP::Request::Common;
16 my $json = JSON->new->utf8;
18 my $mech = Test::WWW::Mechanize::Catalyst->new;
19 ok( my $schema = DBICTest->init_schema(), 'got schema' );
21 my $artist_view_url = "$base/api/rpc/artist/id/";
26 GET( $artist_view_url . $id, undef, 'Accept' => 'application/json' );
28 cmp_ok( $mech->status, '==', 200, 'open attempt okay' );
29 my %expected_response =
30 $schema->resultset('Artist')->find($id)->get_columns;
31 my $response = $json->decode( $mech->content );
34 { data => \%expected_response, success => 'true' },
35 'correct data returned'
42 GET( $artist_view_url . $id, undef, 'Accept' => 'application/json' );
44 cmp_ok( $mech->status, '==', 400, 'open attempt not ok' );
45 my $response = $json->decode( $mech->content );
46 is( $response->{success}, 'false',
47 'not existing object fetch failed ok' );
49 $response->{messages}->[0],
50 qr/^No object found for id/,
51 'error message for not existing object fetch ok'