Thread Mojo - Tests schlagen fehl bei StrawberryPerl (Win7) (14 answers)
Opened by GwenDragon at 2012-05-30 10:19

sri
 2012-06-11 08:07
#158869 #158869
User since
2004-01-29
828 Artikel
BenutzerIn
[Homepage] [default_avatar]
Nein, ich vermute immernoch das es ne kaputte dll sein muss, grenze nur etwas die Art des Bugs ein. Hier is nen Test dessen Ergebnisse sehr aufschlussreich sein sollten.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use Mojo::Base -strict;

use Test::More tests => 6;

use Mojo::IOLoop;
use Mojolicious::Lite;
use Test::Mojo;

# GET /too_long
my $too_long;
get '/too_long' => sub {
my $self = shift;
$self->on(finish => sub { $too_long = 'finished!' });
$self->res->code(200);
$self->res->headers->content_type('text/plain');
$self->res->headers->content_length(1001);
$self->write('x' x 1000);
Mojo::IOLoop->timer(
5 => sub {
$self->write(
sub {
my $self = shift;
$self->write('x');
}
);
}
);
};

my $t = Test::Mojo->new;

# GET /too_long (request timeout)
my $tx = $t->ua->request_timeout(0.5)->build_tx(GET => '/too_long');
my $buffer = '';
$tx->res->body(
sub {
my ($self, $chunk) = @_;
$buffer .= $chunk;
}
);
$t->ua->start($tx);
is $tx->res->code, 200, 'right status';
is $tx->error, 'Request timeout.', 'right error';
is $buffer, 'x' x 1000, 'right content';
$t->ua->request_timeout(0);

# GET /too_long (request timeout)
$tx = $t->ua->request_timeout(3)->build_tx(GET => '/too_long');
$buffer = '';
$tx->res->body(
sub {
my ($self, $chunk) = @_;
$buffer .= $chunk;
}
);
$t->ua->start($tx);
is $tx->res->code, 200, 'right status';
is $tx->error, 'Request timeout.', 'right error';
is $buffer, 'x' x 1000, 'right content';
$t->ua->request_timeout(0);

View full thread Mojo - Tests schlagen fehl bei StrawberryPerl (Win7)