/
base.t
82 lines (76 loc) · 1.84 KB
/
base.t
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use t::Utils;
use Test::More;
use Mock::Web;
my $app = Mock::Web->new;
my $psgi_handler = $app->handler;
subtest 'simple handler test' => sub {
my $env = +{
REQUEST_METHOD => 'GET',
SERVER_PROTOCOL => 'HTTP/1.1',
SERVER_PORT => 80,
SERVER_NAME => 'example.com',
SCRIPT_NAME => '/handler_base_test',
PATH_INFO => '/handler_base_test',
REMOTE_ADDR => '127.0.0.1',
};
my $res = $psgi_handler->($env);
is_deeply $res, [
'200',
[
'Content-Type',
'text/html'
],
[
"handler_base_test is ok\n"
]
];
done_testing;
};
subtest 'args test' => sub {
my $env = +{
REQUEST_METHOD => 'GET',
SERVER_PROTOCOL => 'HTTP/1.1',
SERVER_PORT => 80,
SERVER_NAME => 'example.com',
SCRIPT_NAME => '/args_test',
PATH_INFO => '/args_test',
REMOTE_ADDR => '127.0.0.1',
};
my $res = $psgi_handler->($env);
is_deeply $res, [
'200',
[
'Content-Type',
'text/html'
],
[
"args_test is ok\n"
]
];
done_testing;
};
subtest 'query test' => sub {
my $env = +{
REQUEST_METHOD => 'GET',
SERVER_PROTOCOL => 'HTTP/1.1',
SERVER_PORT => 80,
SERVER_NAME => 'example.com',
SCRIPT_NAME => '/query_test/',
PATH_INFO => '/query_test/',
REMOTE_ADDR => '127.0.0.1',
QUERY_STRING => 'p=query',
};
my $res = $psgi_handler->($env);
is_deeply $res, [
'200',
[
'Content-Type',
'text/html'
],
[
"query is ok\n"
]
];
done_testing;
};
done_testing;