X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-Serialize-Data-Serializer.git;a=blobdiff_plain;f=t%2Fjson.t;fp=t%2Fjson.t;h=0000000000000000000000000000000000000000;hp=6fb604674efdaa74da81481dccaeea841ebad5a9;hb=79025f72c27ba313b3c701cee238f84166f32f9e;hpb=f10c7e1c7eb3b4cb10401dbb86ca8db3dc38ced2 diff --git a/t/json.t b/t/json.t deleted file mode 100644 index 6fb6046..0000000 --- a/t/json.t +++ /dev/null @@ -1,50 +0,0 @@ -use strict; -use warnings; -use Test::More; -use FindBin; - -use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib"); -use Test::Rest; -use utf8; - -eval 'use JSON 2.12'; -plan skip_all => 'Install JSON 2.12 or later to run this test' if ($@); - - -use_ok 'Catalyst::Test', 'Test::Serialize'; - -my $json = JSON->new->utf8; -# The text/x-json should throw a warning -for ('text/x-json', 'application/json') { - my $t = Test::Rest->new('content_type' => $_); - my $monkey_template = { - monkey => 'likes chicken!', - }; - my $mres = request($t->get(url => '/monkey_get')); - ok( $mres->is_success, 'GET the monkey succeeded' ); - is_deeply($json->decode($mres->content), $monkey_template, "GET returned the right data"); - - my $post_data = { - 'sushi' => 'is good for monkey', - 'chicken' => ' 佐藤 純', - }; - my $mres_post = request($t->post(url => '/monkey_put', data => $json->encode($post_data))); - ok( $mres_post->is_success, "POST to the monkey succeeded"); - my $exp = "is good for monkey 佐藤 純"; - utf8::encode($exp); - is_deeply($mres_post->content, $exp, "POST data matches"); -} - -{ - my $t = Test::Rest->new('content_type' => 'application/json'); - my $json_data = '{ "sushi":"is good for monkey", }'; - my $mres_post = request($t->post(url => '/monkey_put', data => $json_data)); - ok( ! $mres_post->is_success, "Got expected failed status due to invalid JSON" ); - - my $relaxed_post = request( $t->post(url => "/monkey_json_put", data => $json_data)); - ok( $relaxed_post->is_success, "Got success due to setting relaxed JSON input" ); -} - -1; - -done_testing;