mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Correct tests modifying mtime of static files
On macOS this resulted in failure because the mtime did not change between test groups. The mtime should now always change.
This commit is contained in:
parent
702c7ff788
commit
36441d35bd
1 changed files with 8 additions and 2 deletions
|
@ -541,10 +541,13 @@ etag_default(Config) ->
|
||||||
|
|
||||||
etag_default_change(Config) ->
|
etag_default_change(Config) ->
|
||||||
doc("Get a file, modify it, get it again and make sure the Etag doesn't match."),
|
doc("Get a file, modify it, get it again and make sure the Etag doesn't match."),
|
||||||
|
%% We set the file to the current time first, then to a time in the past.
|
||||||
|
ok = file:change_time(config(static_dir, Config) ++ "/index.html",
|
||||||
|
calendar:universal_time()),
|
||||||
{200, Headers1, _} = do_get("/dir/index.html", Config),
|
{200, Headers1, _} = do_get("/dir/index.html", Config),
|
||||||
{_, Etag1} = lists:keyfind(<<"etag">>, 1, Headers1),
|
{_, Etag1} = lists:keyfind(<<"etag">>, 1, Headers1),
|
||||||
ok = file:change_time(config(static_dir, Config) ++ "/index.html",
|
ok = file:change_time(config(static_dir, Config) ++ "/index.html",
|
||||||
{{config(port, Config), 1, 1}, {1, 1, 1}}),
|
{{2019, 1, 1}, {1, 1, 1}}),
|
||||||
{200, Headers2, _} = do_get("/dir/index.html", Config),
|
{200, Headers2, _} = do_get("/dir/index.html", Config),
|
||||||
{_, Etag2} = lists:keyfind(<<"etag">>, 1, Headers2),
|
{_, Etag2} = lists:keyfind(<<"etag">>, 1, Headers2),
|
||||||
true = Etag1 =/= Etag2,
|
true = Etag1 =/= Etag2,
|
||||||
|
@ -759,10 +762,13 @@ index_file_slash(Config) ->
|
||||||
|
|
||||||
last_modified(Config) ->
|
last_modified(Config) ->
|
||||||
doc("Get a file, modify it, get it again and make sure Last-Modified changes."),
|
doc("Get a file, modify it, get it again and make sure Last-Modified changes."),
|
||||||
|
%% We set the file to the current time first, then to a time in the past.
|
||||||
|
ok = file:change_time(config(static_dir, Config) ++ "/file.cowboy",
|
||||||
|
calendar:universal_time()),
|
||||||
{200, Headers1, _} = do_get("/dir/file.cowboy", Config),
|
{200, Headers1, _} = do_get("/dir/file.cowboy", Config),
|
||||||
{_, LastModified1} = lists:keyfind(<<"last-modified">>, 1, Headers1),
|
{_, LastModified1} = lists:keyfind(<<"last-modified">>, 1, Headers1),
|
||||||
ok = file:change_time(config(static_dir, Config) ++ "/file.cowboy",
|
ok = file:change_time(config(static_dir, Config) ++ "/file.cowboy",
|
||||||
{{config(port, Config), 1, 1}, {1, 1, 1}}),
|
{{2019, 1, 1}, {1, 1, 1}}),
|
||||||
{200, Headers2, _} = do_get("/dir/file.cowboy", Config),
|
{200, Headers2, _} = do_get("/dir/file.cowboy", Config),
|
||||||
{_, LastModified2} = lists:keyfind(<<"last-modified">>, 1, Headers2),
|
{_, LastModified2} = lists:keyfind(<<"last-modified">>, 1, Headers2),
|
||||||
true = LastModified1 =/= LastModified2,
|
true = LastModified1 =/= LastModified2,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue