File: request_multipart_formdata.t

package info (click to toggle)
libdancer2-perl 1.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,648 kB
  • sloc: perl: 8,589; makefile: 9
file content (40 lines) | stat: -rw-r--r-- 735 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use strict;
use warnings;

use Test::More tests => 2;
use Plack::Test;
use HTTP::Request::Common;
use Ref::Util qw<is_coderef>;


{
    package MyApp;

    use Dancer2;
    our $entity;

    set engines => {
        serializer => {
            JSON => {
                pretty => 1,
            }
        }
    };
    set serializer => 'JSON';

   post '/' => sub {
      template 'index' => { 'title' => 'test_uploads' };
   };

}

my $app = MyApp->to_app;
ok( is_coderef($app), 'Got app' );

my $test = Plack::Test->create($app);

my $filename = 't/app.t';
my $res  = $test->request( POST '/', 
   "Content-Type" => 'multipart/form-data',
   Content => [ filename => [ $filename ] ] );
ok( $res->is_success, '[POST /] successful' );