X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=blobdiff_plain;f=t%2Frpc%2Fsetup_dbic_args.t;h=9cb00eb96efa67f178e4fd278bbadc8f9ad459e3;hp=faa28dd1eaedc7e53051225c1c3bf9d4373312b3;hb=HEAD;hpb=d273984026646e5b57c052deef3fcb9121122060 diff --git a/t/rpc/setup_dbic_args.t b/t/rpc/setup_dbic_args.t index faa28dd..9cb00eb 100644 --- a/t/rpc/setup_dbic_args.t +++ b/t/rpc/setup_dbic_args.t @@ -1,5 +1,3 @@ -use 5.6.0; - use strict; use warnings; @@ -13,25 +11,37 @@ use URI; use Test::More; use Test::WWW::Mechanize::Catalyst 'RestTest'; use HTTP::Request::Common; -use JSON::Any; +use JSON::MaybeXS; + +my $json = JSON::MaybeXS->new(utf8 => 1); my $mech = Test::WWW::Mechanize::Catalyst->new; -ok(my $schema = DBICTest->init_schema(), 'got schema'); +ok( my $schema = DBICTest->init_schema(), 'got schema' ); my $track_list_url = "$base/api/rpc/track_setup_dbic_args/list"; -my $base_rs = $schema->resultset('Track')->search({}, { select => [qw/me.title me.position/], order_by => 'position' }); +my $base_rs = + $schema->resultset('Track') + ->search( {}, + { select => [qw/me.title me.position/], order_by => 'position' } ); # test open request { - my $req = GET( $track_list_url, { - - }, 'Accept' => 'text/x-json' ); - $mech->request($req); - cmp_ok( $mech->status, '==', 200, 'open attempt okay' ); - - my @expected_response = map { { $_->get_columns } } $base_rs->search({ position => { '!=' => '1' } })->all; - my $response = JSON::Any->Load( $mech->content); - is_deeply( { list => \@expected_response, success => 'true' }, $response, 'correct message returned' ); + my $req = GET( + $track_list_url, + { + + }, + 'Accept' => 'text/x-json' + ); + $mech->request($req); + cmp_ok( $mech->status, '==', 200, 'open attempt okay' ); + + my @expected_response = map { + { $_->get_columns } + } $base_rs->search( { position => { '!=' => '1' } } )->all; + my $response = $json->decode( $mech->content ); + is_deeply( { list => \@expected_response, success => 'true' }, + $response, 'correct message returned' ); } done_testing();