Search code examples
perltestingfile-uploadmojolicious

Passing a file as param in Mojolicious controller unit test


I have a file upload application. I want to test my Upload controller. For that how do I pass a file to my test? For file upload in my application I use an external application/plugin (Flash/HTML5/HTML4).


Solution

  • Somehow like this:

    use Test::Mojo;
    
    my $t = Test::Mojo->new('MyApp');
    
    $t->post_form_ok('/my_action', {my_upload => {file => '/path/to/file'}});