From aacc4fa52b4e8b83255280296f1b8a88147fae3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 27 Mar 2020 14:15:15 +0100 Subject: 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. --- src/gun_cookies.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') 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. -- cgit v1.2.3