aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-09-06 12:56:16 +0200
committerLoïc Hoguin <[email protected]>2019-09-06 12:56:16 +0200
commit36441d35bd4e82f8bfca775fbff7e4eabd03397a (patch)
tree8c5de1f3d666bf3bec9c536ff24ded3d36b312c8
parent702c7ff788bdc6e3c7e9da77886b004a8f792906 (diff)
downloadcowboy-36441d35bd4e82f8bfca775fbff7e4eabd03397a.tar.gz
cowboy-36441d35bd4e82f8bfca775fbff7e4eabd03397a.tar.bz2
cowboy-36441d35bd4e82f8bfca775fbff7e4eabd03397a.zip
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.
-rw-r--r--test/static_handler_SUITE.erl10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/static_handler_SUITE.erl b/test/static_handler_SUITE.erl
index 8c0812e..7cee876 100644
--- a/test/static_handler_SUITE.erl
+++ b/test/static_handler_SUITE.erl
@@ -541,10 +541,13 @@ etag_default(Config) ->
etag_default_change(Config) ->
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),
{_, Etag1} = lists:keyfind(<<"etag">>, 1, Headers1),
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),
{_, Etag2} = lists:keyfind(<<"etag">>, 1, Headers2),
true = Etag1 =/= Etag2,
@@ -759,10 +762,13 @@ index_file_slash(Config) ->
last_modified(Config) ->
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),
{_, LastModified1} = lists:keyfind(<<"last-modified">>, 1, Headers1),
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),
{_, LastModified2} = lists:keyfind(<<"last-modified">>, 1, Headers2),
true = LastModified1 =/= LastModified2,