| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Plack::Test::Debugger::ResultGenerator; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Test utility module for generating dummy results |
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
734
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
56
|
|
|
6
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
40
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1804
|
use JSON::XS; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use parent 'Exporter'; |
|
14
|
|
|
|
|
|
|
our @EXPORT = qw[ |
|
15
|
|
|
|
|
|
|
result_generator |
|
16
|
|
|
|
|
|
|
create_root |
|
17
|
|
|
|
|
|
|
create_child |
|
18
|
|
|
|
|
|
|
]; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $FILENAME_FMT = '%s.json'; |
|
21
|
|
|
|
|
|
|
our $JSON = JSON::XS->new->utf8->pretty; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
{ |
|
24
|
|
|
|
|
|
|
my $UID_SEQ = 0; |
|
25
|
|
|
|
|
|
|
my $UID_FMT = '%04d'; |
|
26
|
|
|
|
|
|
|
sub next_UID { sprintf $UID_FMT, ++$UID_SEQ } |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub result_generator { |
|
30
|
|
|
|
|
|
|
my ($uid, $parent_uid) = @_; |
|
31
|
|
|
|
|
|
|
return +{ |
|
32
|
|
|
|
|
|
|
request_uid => $uid, |
|
33
|
|
|
|
|
|
|
uri => 'http://localhost/', |
|
34
|
|
|
|
|
|
|
method => 'GET', |
|
35
|
|
|
|
|
|
|
timestamp => 1111111111, |
|
36
|
|
|
|
|
|
|
results => [ |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
|
|
|
|
|
|
title => 'Tester', |
|
39
|
|
|
|
|
|
|
subtitle => '', |
|
40
|
|
|
|
|
|
|
result => [ |
|
41
|
|
|
|
|
|
|
'before', |
|
42
|
|
|
|
|
|
|
'after', |
|
43
|
|
|
|
|
|
|
'cleanup' |
|
44
|
|
|
|
|
|
|
] |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
], |
|
47
|
|
|
|
|
|
|
($parent_uid ? (parent_request_id => $parent_uid) : ()) |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub create_root { |
|
52
|
|
|
|
|
|
|
my $dir = shift; |
|
53
|
|
|
|
|
|
|
my $root_uid = next_UID; |
|
54
|
|
|
|
|
|
|
$dir->file( sprintf $FILENAME_FMT => $root_uid ) |
|
55
|
|
|
|
|
|
|
->spew( $JSON->encode( result_generator( $root_uid ) ) ); |
|
56
|
|
|
|
|
|
|
return $root_uid; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub create_child { |
|
60
|
|
|
|
|
|
|
my $dir = shift; |
|
61
|
|
|
|
|
|
|
my $root_uid = shift; |
|
62
|
|
|
|
|
|
|
my $sub_uid = next_UID; |
|
63
|
|
|
|
|
|
|
my $sub_dir = $dir->subdir( $root_uid ); |
|
64
|
|
|
|
|
|
|
$sub_dir->mkpath; |
|
65
|
|
|
|
|
|
|
$sub_dir->file( sprintf $FILENAME_FMT => $sub_uid ) |
|
66
|
|
|
|
|
|
|
->spew( $JSON->encode( result_generator( $sub_uid, $root_uid ) ) ); |
|
67
|
|
|
|
|
|
|
return $sub_uid; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |