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 45 46 47
|
use warnings;
use strict;
use Test::More;
use Test::Mojo;
plan skip_all => 't/cgi-bin/file_upload' unless -x 't/cgi-bin/file_upload';
{
use Mojolicious::Lite;
plugin CGI => [ '/file_upload' => 't/cgi-bin/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+)
=== 337
--- --\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;
|