Skip to content

Instantly share code, notes, and snippets.

@bduggan
Created November 10, 2011 15:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bduggan/1355071 to your computer and use it in GitHub Desktop.
Save bduggan/1355071 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
# put.t
use Test::More tests => 3;
use Mojolicious::Lite;
use Test::Mojo;
$ENV{MOJO_MAX_MEMORY_SIZE} = 2; # Force temp files.
$ENV{MOJO_TMPDIR} = "/nosuchdir"; # test setting tempdir dynamically
app->hook(
after_build_tx => sub {
my ( $tx, $app ) = @_;
app->log->warn("after_build_tx");
$tx->req->content->on( body => sub {
my $content = shift;
my $disk = $content->headers->header('X-Disk');
$content->asset->on(
upgrade => sub {
my ( $mem, $file ) = @_;
$file->tmpdir($disk);
}
);
})
}
);
get '/' => sub {
shift->render_text('hi');
};
put '/here' => sub {
shift->render_text('ok');
};
my $t = Test::Mojo->new();
$t->get_ok( '/' )->status_is(200);
$t->put_ok( '/here', { 'X-Disk' => '/tmp' }, 'foo')->status_is(200);
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment