aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-11-19 09:05:34 +0100
committerLoïc Hoguin <[email protected]>2018-11-19 09:05:34 +0100
commitbed328b6c9ce41782c340a89554599a838574d82 (patch)
tree065bd9faad0b6abe234302b599624fe6981fad5d /test/http_SUITE.erl
parent6cc3b0ccca6c06592c2a1881cae39945de805747 (diff)
downloadcowboy-bed328b6c9ce41782c340a89554599a838574d82.tar.gz
cowboy-bed328b6c9ce41782c340a89554599a838574d82.tar.bz2
cowboy-bed328b6c9ce41782c340a89554599a838574d82.zip
Use ?FUNCTION_NAME instead of ct_helper:name()
Cowboy is 19+ so it's OK to use it.
Diffstat (limited to 'test/http_SUITE.erl')
-rw-r--r--test/http_SUITE.erl37
1 files changed, 18 insertions, 19 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index 1d6c3fc..c16215e 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -19,7 +19,6 @@
-import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]).
-import(ct_helper, [get_remote_pid_tcp/1]).
--import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]).
-import(cowboy_test, [raw_open/1]).
-import(cowboy_test, [raw_send/2]).
@@ -43,11 +42,11 @@ init_routes(_) -> [
chunked_false(Config) ->
doc("Confirm the option chunked => false disables chunked "
"transfer-encoding for HTTP/1.1 connections."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
chunked => false
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
Request = "GET /resp/stream_reply2/200 HTTP/1.1\r\nhost: localhost\r\n\r\n",
Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Request),
@@ -69,11 +68,11 @@ chunked_false(Config) ->
http10_keepalive_false(Config) ->
doc("Confirm the option http10_keepalive => false disables keep-alive "
"completely for HTTP/1.0 connections."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
http10_keepalive => false
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
Keepalive = "GET / HTTP/1.0\r\nhost: localhost\r\nConnection: keep-alive\r\n\r\n",
Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Keepalive),
@@ -93,12 +92,12 @@ http10_keepalive_false(Config) ->
idle_timeout_infinity(Config) ->
doc("Ensure the idle_timeout option accepts the infinity value."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
request_timeout => 500,
idle_timeout => infinity
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
_ = gun:post(ConnPid, "/echo/read_body",
[{<<"content-type">>, <<"text/plain">>}]),
@@ -114,11 +113,11 @@ idle_timeout_infinity(Config) ->
request_timeout_infinity(Config) ->
doc("Ensure the request_timeout option accepts the infinity value."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => infinity
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
#{socket := Socket} = gun:info(ConnPid),
Pid = get_remote_pid_tcp(Socket),
@@ -134,11 +133,11 @@ set_options_chunked_false(Config) ->
doc("Confirm the option chunked can be dynamically set to disable "
"chunked transfer-encoding. This results in the closing of the "
"connection after the current request."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
chunked => true
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
Request = "GET /set_options/chunked_false HTTP/1.1\r\nhost: localhost\r\n\r\n",
Client = raw_open([{type, tcp}, {port, Port}, {opts, []}|Config]),
ok = raw_send(Client, Request),
@@ -159,11 +158,11 @@ set_options_chunked_false_ignored(Config) ->
doc("Confirm the option chunked can be dynamically set to disable "
"chunked transfer-encoding, and that it is ignored if the "
"response is not streamed."),
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
chunked => true
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
%% We do a first request setting the option but not
%% using chunked transfer-encoding in the response.
@@ -181,11 +180,11 @@ set_options_idle_timeout(Config) ->
doc("Confirm that the idle_timeout option can be dynamically "
"set to change how long Cowboy will wait before it closes the connection."),
%% We start with a long timeout and then cut it short.
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 60000
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
_ = gun:post(ConnPid, "/set_options/idle_timeout_short",
[{<<"content-type">>, <<"text/plain">>}]),
@@ -202,11 +201,11 @@ set_options_idle_timeout(Config) ->
set_options_idle_timeout_only_applies_to_current_request(Config) ->
doc("Confirm that changes to the idle_timeout option only apply to the current stream."),
%% We start with a long timeout and then cut it short.
- {ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
idle_timeout => 500
}),
- Port = ranch:get_port(name()),
+ Port = ranch:get_port(?FUNCTION_NAME),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
StreamRef = gun:post(ConnPid, "/set_options/idle_timeout_long",
[{<<"content-type">>, <<"text/plain">>}]),
@@ -239,8 +238,8 @@ switch_protocol_flush(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
stream_handlers => [switch_protocol_flush_h]
},
- {ok, _} = cowboy:start_clear(switch_protocol_flush, [{port, 0}], ProtoOpts),
- Port = ranch:get_port(switch_protocol_flush),
+ {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(?FUNCTION_NAME),
Self = self(),
ConnPid = gun_open([{port, Port}, {type, tcp}, {protocol, http}|Config]),
_ = gun:get(ConnPid, "/", [