File: yaws_rpc_SUITE.erl

package info (click to toggle)
yaws 2.1.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,012 kB
  • sloc: erlang: 42,153; sh: 2,501; javascript: 1,459; makefile: 968; ansic: 890; lisp: 79; python: 34; xml: 12; php: 1
file content (55 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download | duplicates (4)
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
-module(yaws_rpc_SUITE).

-include("testsuite.hrl").

-compile(export_all).

all() ->
    [
     unicode
    ].

groups() ->
    [
    ].

%%====================================================================
init_per_suite(Config) ->
    Config.

end_per_suite(_Config) ->
    ok.

init_per_group(_Group, Config) ->
    Config.

end_per_group(_Group, _Config) ->
    ok.

init_per_testcase(_Test, Config) ->
    Config.

end_per_testcase(_Test, _Config) ->
    ok.

%%====================================================================
-define(PARAMS, ["åäö","abc"]).
-define(RESULT, "{\"result\":[\"åäö\",\"abc\"],\"id\":\"id\",\"jsonrpc\":\"2.0\"}").

unicode(_Config) ->
    Payload = json2:encode({struct,[{method,"foo"},{id,"id"},
                                    {params,?PARAMS}]}),
    Req = #http_request{method='POST', version={1,1}},
    Hdrs = #headers{},
    Arg = #arg{clidata=Payload,req=Req,headers=Hdrs},
    Res = yaws_rpc:handler(Arg, {?MODULE, handler}),
    ?assertEqual(200, proplists:get_value(status, Res)),
    {content, Type, Content} = lists:keyfind(content, 1, Res),
    ?assertEqual("application/json", Type),
    ?assertEqual(?RESULT, lists:flatten(Content)),
    ok.

handler(_, {call,foo,{array,?PARAMS}}) ->
    {false, {response, [{array, ?PARAMS}]}}.