Debian Codegraph @

t/issues/gh-794.t

raw
1 use strict;
2 use warnings;
3 use Test::More tests => 2;
4 use Plack::Test;
5 use HTTP::Request::Common;
6
7 {
8 package App;
9 use Dancer2;
10 set serializer => 'JSON';
11
12 post '/' => sub { request->data };
13 }
14
15 my $test = Plack::Test->create( App->to_app );
16
17 is(
18 $test->request( POST '/', Content => '{"foo":42}' )->content,
19 '{"foo":42}',
20 'Correct JSON content in POST',
21 );
22
23 is(
24 $test->request( POST '/', Content => 'invalid' )->code,
25 400,
26 'Failed to decode invalid content',
27 );