diff options
| author | Loïc Hoguin <[email protected]> | 2020-03-27 14:15:15 +0100 | 
|---|---|---|
| committer | Loïc Hoguin <[email protected]> | 2020-03-27 14:15:15 +0100 | 
| commit | aacc4fa52b4e8b83255280296f1b8a88147fae3f (patch) | |
| tree | eac1afe94f2d7f774c5bcda115f11b59e60e9bcb /src | |
| parent | 5a33fda25f34c0d7446ea14e561643ddd0ebe351 (diff) | |
| download | gun-aacc4fa52b4e8b83255280296f1b8a88147fae3f.tar.gz gun-aacc4fa52b4e8b83255280296f1b8a88147fae3f.tar.bz2 gun-aacc4fa52b4e8b83255280296f1b8a88147fae3f.zip | |
Fix time related intermittent error in gun_cookies:gc_test
If we set Max-Age to 1 we may end up GCing the cookie immediately.
Instead we set it to 2 and increase all time values by 1 second.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gun_cookies.erl | 8 | 
1 files changed, 4 insertions, 4 deletions
| diff --git a/src/gun_cookies.erl b/src/gun_cookies.erl index b8fa4da..ce951c6 100644 --- a/src/gun_cookies.erl +++ b/src/gun_cookies.erl @@ -319,13 +319,13 @@ store({Mod, State0}, Cookie) ->  gc_test() ->  	URIMap = #{scheme => <<"http">>, host => <<"example.org">>, path => <<"/path/to/resource">>},  	Store0 = gun_cookies_list:init(), -	%% Add a cookie that expires in 1 second. GC. Cookie can be retrieved. -	{ok, N0, V0, A0} = cow_cookie:parse_set_cookie(<<"a=b; Path=/; Max-Age=1">>), +	%% Add a cookie that expires in 2 seconds. GC. Cookie can be retrieved. +	{ok, N0, V0, A0} = cow_cookie:parse_set_cookie(<<"a=b; Path=/; Max-Age=2">>),  	{ok, Store1} = set_cookie(Store0, URIMap, N0, V0, A0),  	{ok, Store2} = gc(Store1),  	{ok, [_], _} = query(Store2, URIMap), -	%% Wait 2 seconds. GC. Cookie was removed. -	timer:sleep(2000), +	%% Wait 3 seconds. GC. Cookie was removed. +	timer:sleep(3000),  	{ok, Store} = gc(Store2),  	{ok, [], _} = query(Store, URIMap),  	ok. | 
