aboutsummaryrefslogtreecommitdiffstats
path: root/test/misc_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-10-02 16:19:13 +0200
committerLoïc Hoguin <[email protected]>2017-10-02 16:19:13 +0200
commit9317751cb314328340fede4cb780562b77afe8c9 (patch)
treeab876bb3355acb0b3980b391f408ab3b50972336 /test/misc_SUITE.erl
parent6460e9d2d270cffe2074053af224af7ce94ce098 (diff)
downloadcowboy-9317751cb314328340fede4cb780562b77afe8c9.tar.gz
cowboy-9317751cb314328340fede4cb780562b77afe8c9.tar.bz2
cowboy-9317751cb314328340fede4cb780562b77afe8c9.zip
Fix cowboy:set_env when the env value is missing
Diffstat (limited to 'test/misc_SUITE.erl')
-rw-r--r--test/misc_SUITE.erl20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/misc_SUITE.erl b/test/misc_SUITE.erl
index 87e7189..a848e44 100644
--- a/test/misc_SUITE.erl
+++ b/test/misc_SUITE.erl
@@ -20,11 +20,14 @@
-import(cowboy_test, [gun_open/1]).
all() ->
- cowboy_test:common_all().
+ [{group, no_env}|cowboy_test:common_all()].
groups() ->
- cowboy_test:common_groups(ct_helper:all(?MODULE)).
+ Common = ct_helper:all(?MODULE) -- [set_env_missing],
+ [{no_env, [], [set_env_missing]}|cowboy_test:common_groups(Common)].
+init_per_group(Name=no_env, Config) ->
+ cowboy_test:init_http(Name, #{}, Config);
init_per_group(Name, Config) ->
cowboy_test:init_common_groups(Name, Config, ?MODULE).
@@ -48,3 +51,16 @@ set_env(Config) ->
Ref2 = gun:get(ConnPid2, "/"),
{response, _, 400, _} = gun:await(ConnPid2, Ref2),
ok.
+
+set_env_missing(Config) ->
+ doc("Live replace a middleware environment value when env was not provided."),
+ ConnPid1 = gun_open(Config),
+ Ref1 = gun:get(ConnPid1, "/"),
+ {response, _, 500, _} = gun:await(ConnPid1, Ref1),
+ Listener = proplists:get_value(name, config(tc_group_properties, Config)),
+ cowboy:set_env(Listener, dispatch, []),
+ %% Only new connections get the updated environment.
+ ConnPid2 = gun_open(Config),
+ Ref2 = gun:get(ConnPid2, "/"),
+ {response, _, 400, _} = gun:await(ConnPid2, Ref2),
+ ok.