Debian Codegraph @

t/request_multipart_formdata.t

raw
1 use strict;
2 use warnings;
3
4 use Test::More tests => 2;
5 use Plack::Test;
6 use HTTP::Request::Common;
7 use Ref::Util qw<is_coderef>;
8
9
10 {
11 package MyApp;
12
13 use Dancer2;
14 our $entity;
15
16 set engines => {
17 serializer => {
18 JSON => {
19 pretty => 1,
20 }
21 }
22 };
23 set serializer => 'JSON';
24
25 post '/' => sub {
26 template 'index' => { 'title' => 'test_uploads' };
27 };
28
29 }
30
31 my $app = MyApp->to_app;
32 ok( is_coderef($app), 'Got app' );
33
34 my $test = Plack::Test->create($app);
35
36 my $filename = 't/app.t';
37 my $res = $test->request( POST '/',
38 "Content-Type" => 'multipart/form-data',
39 Content => [ filename => [ $filename ] ] );
40 ok( $res->is_success, '[POST /] successful' );