Commit | Line | Data |
d2739840 |
1 | use 5.6.0; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use lib 't/lib'; |
7 | |
8 | my $base = 'http://localhost'; |
9 | |
10 | use RestTest; |
11 | use DBICTest; |
12 | use URI; |
13 | use Test::More; |
14 | use Test::WWW::Mechanize::Catalyst 'RestTest'; |
15 | use HTTP::Request::Common; |
16 | use JSON::Any; |
17 | |
18 | my $mech = Test::WWW::Mechanize::Catalyst->new; |
19 | ok(my $schema = DBICTest->init_schema(), 'got schema'); |
20 | |
21 | my $track_list_url = "$base/api/rpc/track_setup_dbic_args/list"; |
22 | my $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 | |
37 | done_testing(); |