File: multipart.t

package info (click to toggle)
libmojolicious-plugin-cgi-perl 0.36-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 208 kB
  • ctags: 17
  • sloc: perl: 300; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 847 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
41
42
43
44
use t::Helper;

use Mojolicious::Lite;
plugin CGI => ['/file_upload' => cgi_script('file_upload')];

my $t = Test::Mojo->new;

$t->post_ok(
  '/file_upload' => form => {
    mytext => [
      {file => 't/foo.txt'},
      {file => 't/bar.txt'},
      {file => 't/test_file_with_a_long_filename.txt'},
    ]
  }
);
$t->status_is(200);

$t->content_like(
  qr{^\d+
=== multipart/form-data; boundary=(\w+)
=== \d+
--- --\1\r
--- Content-Disposition: form-data; name="mytext"; filename="foo\.txt"\r
--- \r
--- some more
--- data
--- \r
--- --\1\r
--- Content-Disposition: form-data; name="mytext"; filename="bar\.txt"\r
--- \r
--- even more
--- data here
--- \r
--- --\1\r
--- Content-Disposition: form-data; name="mytext"; filename="test_file_with_a_long_filename\.txt"\r
--- \r
--- and yet more
--- data in here
--- \r
--- --\1--}s
);

done_testing;