Modified:
branches/RB-0.2/lib/ewgi/test/src/mochiweb_hello.erl
branches/RB-0.2/lib/ewgi/test/src/mochiweb_simple_get.erl
branches/RB-0.2/lib/ewgi/test/src/mochiweb_simple_post.erl
Log:
fixed tests to the new specs
Modified: branches/RB-0.2/lib/ewgi/test/src/mochiweb_hello.erl
==============================================================================
--- branches/RB-0.2/lib/ewgi/test/src/mochiweb_hello.erl (original)
+++ branches/RB-0.2/lib/ewgi/test/src/mochiweb_hello.erl Mon Oct 20
13:50:01 2008
@@ -3,6 +3,8 @@
-define(DEFAULTS, [{name, ?MODULE},
{port, 8084}]).
+-include("../../include/ewgi.hrl").
+
start() ->
mochiweb_http:start([{loop, fun ?MODULE:loop/1} | ?DEFAULTS]).
@@ -10,7 +12,9 @@
mochiweb_http:stop(?MODULE).
loop(Req) ->
+ error_logger:error_report(Req),
M = ewgi_mochiweb:new(fun ?MODULE:handle_req/1),
+ error_logger:error_report(Req),
M:run(Req).
handle_req(Ctx) ->
Modified: branches/RB-0.2/lib/ewgi/test/src/mochiweb_simple_get.erl
==============================================================================
--- branches/RB-0.2/lib/ewgi/test/src/mochiweb_simple_get.erl (original)
+++ branches/RB-0.2/lib/ewgi/test/src/mochiweb_simple_get.erl Mon Oct 20
13:50:01 2008
@@ -50,7 +50,14 @@
?true((Qs=="") or (Qs==?DATA)),
?eq(ewgi_api:content_type(Ctx), undefined),
?eq(ewgi_api:content_length(Ctx), undefined),
- Headers = [{"HTTP_CONNECTION", "keep-alive"},
{"HTTP_HOST", "localhost"}, {"HTTP_TE", []}],
+ Headers = [{"accept", undefined},
+ {"cookie", undefined},
+ {"host", "localhost"},
+ {"if-modified-since", undefined},
+ {"user-agent", undefined},
+ {"x-http-method-override", undefined},
+ {"te", []},
+ {"connection", "keep-alive"}],
?eq(ewgi_api:get_all_headers(Ctx), Headers),
?eq(ewgi_api:remote_host(Ctx), undefined),
?eq(ewgi_api:remote_addr(Ctx), "127.0.0.1"),
@@ -59,8 +66,8 @@
?eq(ewgi_api:remote_ident(Ctx),undefined),
?eq(ewgi_api:url_scheme(Ctx), "http"),
?eq(ewgi_api:version(Ctx), {1, 0}),
- ?eq(ewgi_api:get_all_data(Ctx), []),
- {ewgi_context, [], {?OK, [], ?RESPONSE}}.
+ ?eq(ewgi_api:get_all_data(Ctx), dict:new()),
+ {ewgi_context, #ewgi_request{}, #ewgi_response{status=?OK, headers=[],
message_body=?RESPONSE}}.
test_simple_req() ->
{ok, Result} = http:request("http://localhost:8000/"),
Modified: branches/RB-0.2/lib/ewgi/test/src/mochiweb_simple_post.erl
==============================================================================
--- branches/RB-0.2/lib/ewgi/test/src/mochiweb_simple_post.erl (original)
+++ branches/RB-0.2/lib/ewgi/test/src/mochiweb_simple_post.erl Mon Oct 20
13:50:01 2008
@@ -34,24 +34,29 @@
handle_req(Ctx) ->
{ewgi_context, Req, _Resp} = Ctx,
- ?eq(ewgi_api:server_sw(Ctx), "MochiWeb"),
+ ?eq(ewgi_api:server_software(Ctx), "MochiWeb"),
?eq(ewgi_api:server_name(Ctx), "localhost"),
- ?eq(ewgi_api:gw_interface(Ctx),"EWGI/1.0"),
+ ?eq(ewgi_api:gateway_interface(Ctx),"EWGI/1.0"),
?eq(ewgi_api:server_protocol(Ctx), "HTTP/1.1"),
?eq(ewgi_api:server_port(Ctx), 8000),
- ?eq(ewgi_api:method(Ctx), 'POST'),
+ ?eq(ewgi_api:request_method(Ctx), 'POST'),
?eq(ewgi_api:path_info(Ctx), "/"),
?eq(ewgi_api:path_translated(Ctx), undefined),
?eq(ewgi_api:script_name(Ctx), ""),
% same hanlder for 2 GET requests.
% one has a query string and one hasn't
% check for both
- ?eq(ewgi_api:qs(Ctx),""),
+ ?eq(ewgi_api:query_string(Ctx),""),
?eq(ewgi_api:content_type(Ctx), ?CONTENT_TYPE),
?eq(ewgi_api:content_length(Ctx), length(?DATA)),
- Headers = [{"HTTP_CONNECTION", "keep-alive"},
- {"HTTP_HOST", "localhost"},
- {"HTTP_TE", []}],
+ Headers = [{"accept", undefined},
+ {"cookie", undefined},
+ {"host", "localhost"},
+ {"if-modified-since", undefined},
+ {"user-agent", undefined},
+ {"x-http-method-override", undefined},
+ {"te", []},
+ {"connection", "keep-alive"}],
?eq(ewgi_api:get_all_headers(Ctx), Headers),
?eq(ewgi_api:remote_host(Ctx), undefined),
?eq(ewgi_api:remote_addr(Ctx), "127.0.0.1"),
@@ -60,8 +65,8 @@
?eq(ewgi_api:remote_ident(Ctx),undefined),
?eq(ewgi_api:url_scheme(Ctx), "http"),
?eq(ewgi_api:version(Ctx), {1, 0}),
- ?eq(ewgi_api:get_all_data(Ctx), []),
- {ewgi_context, Req, {?OK, [], ?RESPONSE}}.
+ ?eq(ewgi_api:get_all_data(Ctx), dict:new()),
+ {ewgi_context, Req, #ewgi_response{status=?OK, headers=[],
message_body=?RESPONSE}}.
test_simple_post() ->
{ok, Result} = http:request(post, {"http://localhost:8000/",