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