Skip to content

Instantly share code, notes, and snippets.

@sharifulin
Created December 24, 2010 17:39
Show Gist options
  • Save sharifulin/754417 to your computer and use it in GitHub Desktop.
Save sharifulin/754417 to your computer and use it in GitHub Desktop.
Upload bug
#!/usr/bin/env perl
use common::sense;
use lib 'lib';
use Mojolicious::Lite;
use Test::Mojo;
use Test::More tests => 8;
use Data::Dumper;
post '/' => sub {
my $self = shift;
$self->render_json({
map { $_ => $self->req->upload( $_ ) || '' } qw(ipa_file plist_file),
});
};
post '/reverse' => sub {
my $self = shift;
$self->render_json({
map { $_ => $self->req->upload( $_ ) || '' } reverse qw(ipa_file plist_file), # ONLY reverse
});
};
my $t = Test::Mojo->new;
my $json;
$json = $t->post_form_ok('/', {
ipa_file => { content => '1111' },
plist_file => { content => '111132222222' },
})
->status_is(200)
->tx->res->json
;
# warn Dumper $json;
like $json->{ipa_file }, qr/Mojo::Upload/, 'ipa_file ok';
like $json->{plist_file}, qr/Mojo::Upload/, 'plist_file ok';
# reverse version
$json = $t->post_form_ok('/reverse', {
ipa_file => { content => '1111' },
plist_file => { content => '111132222222' },
})
->status_is(200)
->tx->res->json
;
# warn Dumper $json;
like $json->{ipa_file}, qr/Mojo::Upload/, 'ipa_file ok';
like $json->{plist_file}, qr/Mojo::Upload/, 'plist_file ok';
__END__
$ perl test_upload.pl
1..8
ok 1 - post /
ok 2 - 200 OK
ok 3 - ipa_file ok
not ok 4 - plist_file ok
# Failed test 'plist_file ok'
# at test_upload.pl line 42.
# ''
# doesn't match '(?-xism:Mojo::Upload)'
ok 5 - post /reverse
ok 6 - 200 OK
ok 7 - ipa_file ok
ok 8 - plist_file ok
# Looks like you failed 1 test of 8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment