Skip to content

Instantly share code, notes, and snippets.

@sugar84
Created October 5, 2011 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sugar84/1264816 to your computer and use it in GitHub Desktop.
Save sugar84/1264816 to your computer and use it in GitHub Desktop.
upload bug?
#!/usr/bin/env perl
use Mojolicious::Lite;
# create file for testing
my $file = "yet_another_file";
qx(touch $file; echo "hello" > $file);
any '/' => sub {
my $self = shift;
my $file = $self->param("doc");
return $file
? $self->render(text => "ok")
: $self->render(text => $self->dumper($self->req->params->to_hash) ) # show params
;
};
use Test::Mojo;
use Test::More tests => 6;
my $t = Test::Mojo->new;
ok((-f $file), "file exists");
$t->get_ok('/');
$t->post_form_ok('/',
{ doc => {file => $file} }
)
->status_is(200)
->content_is("ok") # 'ok' when upload is successful
;
# remove testing file
qx(rm -f $file);
ok(!(-f $file), "file not exists");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment