added REST and RPC delete_bulk tests and fixed RPC delete_bulk not working at all
[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;
16use JSON::Any;
17
18my $mech = Test::WWW::Mechanize::Catalyst->new;
19ok(my $schema = DBICTest->init_schema(), 'got schema');
20
21my $track_list_url = "$base/api/rpc/track_setup_dbic_args/list";
22my $base_rs = $schema->resultset('Track')->search({}, { select => [qw/me.title me.position/], order_by => 'position' });
23
24# test open request
25{
26 my $req = GET( $track_list_url, {
27
28 }, 'Accept' => 'text/x-json' );
29 $mech->request($req);
30 cmp_ok( $mech->status, '==', 200, 'open attempt okay' );
31
32 my @expected_response = map { { $_->get_columns } } $base_rs->search({ position => { '!=' => '1' } })->all;
33 my $response = JSON::Any->Load( $mech->content);
34 is_deeply( { list => \@expected_response, success => 'true' }, $response, 'correct message returned' );
35}
36
37done_testing();