-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Utility functions for testing | ||
|
||
function ignore_output(body::Function; stdout::Bool=true, stderr::Bool=true) | ||
out_old = STDOUT | ||
err_old = STDERR | ||
|
||
if stdout | ||
(out_rd, out_wr) = redirect_stdout() | ||
end | ||
if stderr | ||
(err_rd, err_wr) = redirect_stderr() | ||
end | ||
|
||
result = body() | ||
|
||
if stdout | ||
redirect_stdout(out_old) | ||
close(out_wr) | ||
close(out_rd) | ||
end | ||
if stderr | ||
redirect_stderr(err_old) | ||
close(err_wr) | ||
close(err_rd) | ||
end | ||
|
||
return result | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import TimeZones.TZData: tzdata_url, tzdata_download, isarchive | ||
|
||
@test tzdata_url("2016j") == "https://www.iana.org/time-zones/repository/releases/tzdata2016j.tar.gz" | ||
@test tzdata_url("latest") == "https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz" | ||
|
||
# Note: Try to keep the number of `tzdata_download` calls low to avoid unnecessary network traffic | ||
mktempdir() do temp_dir | ||
file_path = ignore_output() do | ||
tzdata_download("latest", temp_dir) | ||
end | ||
|
||
@test isfile(file_path) | ||
@test isarchive(file_path) | ||
@test basename(file_path) != basename(tzdata_url("latest")) | ||
|
||
last_modified = mtime(file_path) | ||
last_file_path = file_path | ||
|
||
# No need to ignore output as this should never trigger a download | ||
file_path = tzdata_download("latest", temp_dir) | ||
|
||
@test file_path == last_file_path | ||
@test mtime(file_path) == last_modified | ||
end |