-
Notifications
You must be signed in to change notification settings - Fork 3
/
http2.t
36 lines (30 loc) · 789 Bytes
/
http2.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
use Cro::HTTP::Test;
sub routes() is export {
use Cro::HTTP::Router;
route {
get -> {
content 'text/plain', 'Nothing to see here';
}
post -> 'add' {
request-body 'application/json' => -> (:$x!, :$y!) {
content 'application/json', { :result($x + $y) };
}
}
}
}
plan 4;
test-service routes(), :http<2>, {
test get('/'),
status => 200,
content-type => 'text/plain',
body => /:i nothing/;
test-given '/add', {
test post(json => { :x(37), :y(5) }),
status => 200,
json => { :result(42) };
test post(json => { :x(37) }),
status => 400;
test get(json => { :x(37) }),
status => 405;
}
}