use JSON instead of JSON::Any to get rid of the CPAN Testers failures when only JSON...
[catagits/Catalyst-Controller-DBIC-API.git] / t / rpc / setup_dbic_args.t
CommitLineData
d2739840 1use 5.6.0;
2
3use strict;
4use warnings;
5
6use lib 't/lib';
7
8my $base = 'http://localhost';
9
10use RestTest;
11use DBICTest;
12use URI;
13use Test::More;
14use Test::WWW::Mechanize::Catalyst 'RestTest';
15use HTTP::Request::Common;
0b0bf911 16use JSON;
17
18my $json = JSON->new->utf8;
d2739840 19
20my $mech = Test::WWW::Mechanize::Catalyst->new;
0b0bf911 21ok( my $schema = DBICTest->init_schema(), 'got schema' );
d2739840 22
23my $track_list_url = "$base/api/rpc/track_setup_dbic_args/list";
0b0bf911 24my $base_rs =
25 $schema->resultset('Track')
26 ->search( {},
27 { select => [qw/me.title me.position/], order_by => 'position' } );
d2739840 28
29# test open request
30{
0b0bf911 31 my $req = GET(
32 $track_list_url,
33 {
34
35 },
36 'Accept' => 'text/x-json'
37 );
38 $mech->request($req);
39 cmp_ok( $mech->status, '==', 200, 'open attempt okay' );
40
41 my @expected_response = map {
42 { $_->get_columns }
43 } $base_rs->search( { position => { '!=' => '1' } } )->all;
44 my $response = $json->decode( $mech->content );
45 is_deeply( { list => \@expected_response, success => 'true' },
46 $response, 'correct message returned' );
d2739840 47}
48
49done_testing();