Created
November 10, 2011 15:11
-
-
Save bduggan/1355071 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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