From 25a17a259056f8343f042553f9a0394309c9d928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 22 Apr 2014 22:50:45 +0200 Subject: Move listener initialization to cowboy_test --- test/cowboy_test.erl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/cowboy_test.erl') diff --git a/test/cowboy_test.erl b/test/cowboy_test.erl index 786eab6..4cb2a33 100644 --- a/test/cowboy_test.erl +++ b/test/cowboy_test.erl @@ -49,6 +49,34 @@ all(Suite) -> string:substr(atom_to_list(F), 1, 3) =/= "do_" ]). +%% Listeners initialization. + +init_http(Ref, ProtoOpts, Config) -> + {ok, _} = cowboy:start_http(Ref, 100, [{port, 0}], [ + {max_keepalive, 50}, + {timeout, 500} + |ProtoOpts]), + Port = ranch:get_port(Ref), + [{type, tcp}, {port, Port}, {opts, []}|Config]. + +init_https(Ref, ProtoOpts, Config) -> + {_, Cert, Key} = ct_helper:make_certs(), + Opts = [{cert, Cert}, {key, Key}], + {ok, _} = cowboy:start_https(Ref, 100, Opts ++ [{port, 0}], [ + {max_keepalive, 50}, + {timeout, 500} + |ProtoOpts]), + Port = ranch:get_port(Ref), + [{type, ssl}, {port, Port}, {opts, Opts}|Config]. + +init_spdy(Ref, ProtoOpts, Config) -> + {_, Cert, Key} = ct_helper:make_certs(), + Opts = [{cert, Cert}, {key, Key}], + {ok, _} = cowboy:start_spdy(Ref, 100, Opts ++ [{port, 0}], + ProtoOpts), + Port = ranch:get_port(Ref), + [{type, ssl}, {port, Port}, {opts, Opts}|Config]. + %% Support functions for testing using Gun. gun_open(Config) -> -- cgit v1.2.3