about summary refs log tree commit diff
path: root/t/lib/TestAPI.pm
blob: 4f7873e84717a0c07344162745bb7e762333f281 (plain) (blame)
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
package TestAPI;
use Net::HTTP::API;

use HTTP::Response;

net_api_declare fake_api => (
    api_base_url   => 'http://exemple.com',
    format         => 'json',
    format_options => { utf8 => 1, }
);

net_api_method users => (
    method   => 'GET',
    path     => '/users/',
    expected => [qw/200/],
);

net_api_method user => (
    method   => 'GET',
    path     => '/user/:user_name/:last_name',
    params   => [qw/user_name last_name/],
    required => [qw/user_name/],
    expected => [qw/200/],
);

net_api_method add_user => (
    method   => 'POST',
    path     => '/user/',
    params   => [qw/name dob/],
    required => [qw/name/],
    expected => [qw/201/],
);

net_api_method update_user => (
    method   => 'PUT',
    path     => '/user/:name',
    params   => [qw/name dob/],
    required => [qw/name/],
    expected => [qw/201/],
);

net_api_method delete_user => (
    method   => 'DELETE',
    path     => '/user/:name',
    params   => [qw/name/],
    required => [qw/name/],
    expected => [qw/204/],
);

net_api_method unstrict_users => (
    method   => 'GET',
    path     => '/users/unstrict',
    strict   => 0,
    params   => [qw/name/],
    required => [qw/name/],
);

net_api_method params_users => (
    method        => 'POST',
    path          => '/users/',
    params        => [qw/name/],
    params_in_url => [qw/bod/],
    required      => [qw/bod name/],
);

1;