line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RapidApp::Test; |
2
|
4
|
|
|
4
|
|
2820722
|
use base 'Catalyst::Test'; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
1973
|
|
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
148728
|
use strict; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
83
|
|
5
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
104
|
|
6
|
4
|
|
|
4
|
|
2602
|
use Import::Into; |
|
4
|
|
|
|
|
1870
|
|
|
4
|
|
|
|
|
131
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
605
|
use Time::HiRes qw(gettimeofday tv_interval); |
|
4
|
|
|
|
|
1611
|
|
|
4
|
|
|
|
|
43
|
|
9
|
4
|
|
|
4
|
|
2518
|
use HTTP::Request::Common; |
|
4
|
|
|
|
|
9044
|
|
|
4
|
|
|
|
|
287
|
|
10
|
4
|
|
|
4
|
|
3030
|
use JSON qw(decode_json); |
|
4
|
|
|
|
|
33516
|
|
|
4
|
|
|
|
|
24
|
|
11
|
4
|
|
|
4
|
|
476
|
use Catalyst::Utils; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
90
|
|
12
|
4
|
|
|
4
|
|
1741
|
use RapidApp::Test::Client; |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
610
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $target; |
15
|
|
|
|
|
|
|
my $app_class; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
4
|
|
|
4
|
|
47
|
$target = caller; |
19
|
4
|
|
|
|
|
14
|
my ($self, $class, @args) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Since apps might take a while to start-up: |
22
|
4
|
|
|
|
|
33
|
pass("[RapidApp::Test]: loading testapp '$class'..."); |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
2779
|
my $start = [gettimeofday]; |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
23
|
require_ok($class); |
27
|
4
|
|
|
|
|
4493
|
Catalyst::Test->import::into($target,$class,@args); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my @funcs = grep { |
30
|
4
|
100
|
|
|
|
5248
|
$_ ne 'import' && $_ ne 'AUTOLOAD' |
|
28
|
|
|
|
|
5407
|
|
31
|
|
|
|
|
|
|
} Class::MOP::Class->initialize(__PACKAGE__)->get_method_list; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Manually export our functions: |
34
|
|
|
|
|
|
|
{ |
35
|
4
|
|
|
4
|
|
37
|
no strict 'refs'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
2213
|
|
|
4
|
|
|
|
|
12
|
|
36
|
4
|
|
|
|
|
14
|
*{ join('::',$target,$_) } = \*{ $_ } for (@funcs); |
|
20
|
|
|
|
|
110
|
|
|
20
|
|
|
|
|
43
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
ok( |
40
|
4
|
|
66
|
|
|
29
|
$class->setup_finished || $class->setup, |
41
|
|
|
|
|
|
|
sprintf("$class loaded/started (%0.4f seconds)",tv_interval($start)) |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
42109
|
$app_class = $class; |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
our $AUTOLOAD; |
48
|
|
|
|
|
|
|
sub AUTOLOAD { |
49
|
82
|
|
|
82
|
|
2273
|
my $method = (reverse(split('::',$AUTOLOAD)))[0]; |
50
|
82
|
|
|
|
|
1023
|
$target->can($method)->(@_); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
## Setup the "client" object |
54
|
88
|
|
|
88
|
0
|
20809
|
my $Client; sub client { $Client } |
55
|
|
|
|
|
|
|
$Client = RapidApp::Test::Client->new({ request_caller => sub { |
56
|
|
|
|
|
|
|
my $req = shift; |
57
|
|
|
|
|
|
|
ok( |
58
|
|
|
|
|
|
|
my $res = client->record_response( request($req) ), |
59
|
|
|
|
|
|
|
client->describe_request |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
return $res; |
62
|
|
|
|
|
|
|
}}); |
63
|
|
|
|
|
|
|
## |
64
|
|
|
|
|
|
|
|
65
|
6
|
|
|
6
|
0
|
188
|
sub app_class { $app_class } |
66
|
3
|
|
|
3
|
0
|
15
|
sub app_version { eval(join('','$',app_class(),'::VERSION')) } |
67
|
0
|
|
|
0
|
0
|
0
|
sub app_prefix { Catalyst::Utils::appprefix(app_class()) } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# These are tests which should pass for all RapidApp applications: |
70
|
|
|
|
|
|
|
# TODO: refactor into Test::Client |
71
|
|
|
|
|
|
|
sub run_common_tests { |
72
|
|
|
|
|
|
|
|
73
|
3
|
|
|
3
|
0
|
594
|
ok($RapidApp::VERSION, 'RapidApp $VERSION ('.$RapidApp::VERSION.')'); |
74
|
|
|
|
|
|
|
|
75
|
3
|
|
|
|
|
1868
|
my $ver = app_version; |
76
|
3
|
|
|
|
|
16
|
ok($ver, 'App (' . app_class(). ') $VERSION ('.$ver.')'); |
77
|
|
|
|
|
|
|
|
78
|
3
|
|
|
|
|
1093
|
action_ok( |
79
|
|
|
|
|
|
|
'/assets/rapidapp/misc/static/images/rapidapp_powered_logo_tiny.png', |
80
|
|
|
|
|
|
|
"Fetched RapidApp logo from the Misc asset controller" |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
5176
|
action_ok( |
84
|
|
|
|
|
|
|
'/any/prefix/path/_ra-rel-mnt_/assets/rapidapp/misc/static/images/rapidapp_powered_logo_tiny.png', |
85
|
|
|
|
|
|
|
"Fetched RapidApp logo from the Misc asset controller (via _ra-rel-mnt_)" |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
3
|
|
|
|
|
5216
|
action_notfound( |
89
|
|
|
|
|
|
|
'/assets/rapidapp/misc/static/some/bad/file.txt', |
90
|
|
|
|
|
|
|
"Invalid asset path not found as expected" |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
3
|
|
|
|
|
1440
|
action_notfound( |
94
|
|
|
|
|
|
|
'/any/prefix/path/_ra-rel-mnt_/assets/rapidapp/misc/static/some/bad/file.txt', |
95
|
|
|
|
|
|
|
"Invalid asset path not found as expected (via _ra-rel-mnt_)" |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |