line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
20358
|
use 5.008001; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
78
|
|
2
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
142
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dancer2::Plugin::Queue::Role::Test; |
6
|
|
|
|
|
|
|
# ABSTRACT: A Test::Roo::Role for testing Queue backends |
7
|
|
|
|
|
|
|
our $VERSION = '0.004'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1472
|
use Test::Roo::Role; |
|
2
|
|
|
|
|
586
|
|
|
2
|
|
|
|
|
14
|
|
10
|
2
|
|
|
2
|
|
2382
|
use MooX::Types::MooseLike::Base qw/Str HashRef CodeRef/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
122
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
2048
|
use HTTP::Tiny; |
|
2
|
|
|
|
|
112638
|
|
|
2
|
|
|
|
|
138
|
|
13
|
2
|
|
|
2
|
|
1524
|
use Test::TCP; |
|
2
|
|
|
|
|
81216
|
|
|
2
|
|
|
|
|
292
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has backend => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => Str, |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has options => ( |
24
|
|
|
|
|
|
|
is => 'lazy', |
25
|
|
|
|
|
|
|
isa => HashRef, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
0
|
|
0
|
sub _build_options { } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has _server => ( |
31
|
|
|
|
|
|
|
is => 'lazy', |
32
|
|
|
|
|
|
|
isa => CodeRef, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _build__server { |
36
|
2
|
|
|
2
|
|
1248
|
my ($self) = @_; |
37
|
|
|
|
|
|
|
return sub { |
38
|
|
|
|
|
|
|
package |
39
|
|
|
|
|
|
|
MyServer; |
40
|
2
|
|
|
2
|
|
1606
|
use Dancer2 ':syntax'; |
|
2
|
|
|
|
|
626238
|
|
|
2
|
|
|
|
|
16
|
|
41
|
2
|
|
|
2
|
|
213762
|
use Dancer2::Plugin::Queue; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
14
|
|
42
|
1
|
|
|
1
|
|
9826
|
my $port = shift; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
80
|
set confdir => '.'; |
45
|
1
|
|
|
|
|
816
|
set startup_info => 0; |
46
|
1
|
|
|
|
|
283
|
set show_errors => 1; |
47
|
1
|
|
|
|
|
133
|
set plugins => { |
48
|
|
|
|
|
|
|
Queue => { |
49
|
|
|
|
|
|
|
default => { |
50
|
|
|
|
|
|
|
class => $self->backend, |
51
|
|
|
|
|
|
|
options => $self->options, |
52
|
|
|
|
|
|
|
}, |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
get '/add' => sub { |
57
|
0
|
|
|
|
|
0
|
queue->add_msg( params->{msg} ); |
58
|
0
|
|
|
|
|
0
|
my ( $msg, $body ) = queue->get_msg; |
59
|
0
|
|
|
|
|
0
|
queue->remove_msg($msg); |
60
|
0
|
|
|
|
|
0
|
return $body; |
61
|
1
|
|
|
|
|
2118
|
}; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
6648
|
Dancer2->runner->server->port($port); |
64
|
0
|
|
|
|
|
|
start; |
65
|
2
|
|
|
|
|
54
|
}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
test 'queue and dequeue' => sub { |
69
|
|
|
|
|
|
|
my $self = shift; |
70
|
|
|
|
|
|
|
test_tcp( |
71
|
|
|
|
|
|
|
client => sub { |
72
|
|
|
|
|
|
|
my $port = shift; |
73
|
|
|
|
|
|
|
my $url = "http://localhost:$port/"; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $ua = HTTP::Tiny->new; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $res = $ua->get( $url . "add?msg=Hello%20World" ); |
78
|
|
|
|
|
|
|
like $res->{content}, qr/Hello World/i, "sent and receieved message"; |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
server => $self->_server, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# vim: ts=4 sts=4 sw=4 et: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |