-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Parametrize iana database download_url
- Loading branch information
Showing
11 changed files
with
184 additions
and
75 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ erl_crash.dump | |
*.ez | ||
/doc | ||
/priv/latest_remote_poll.txt | ||
/priv/tmp_downloads |
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 @@ | ||
1.2.0 |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
# This file is responsible for configuring your application | ||
# and its dependencies with the aid of the Mix.Config module. | ||
use Mix.Config | ||
import Config | ||
|
||
config :logger, utc_log: true | ||
config :tzdata, :autoupdate, :enabled | ||
|
||
config :tzdata, download_url: "https://data.iana.org/time-zones/tzdata-latest.tar.gz" | ||
# config :tzdata, :data_dir, "/etc/elixir_tzdata_storage" |
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
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
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,52 @@ | ||
defmodule Tzdata.DataLoaderTest do | ||
use ExUnit.Case, async: false | ||
alias Tzdata.HTTPClient.Mock | ||
doctest Tzdata.DataLoader | ||
import Mox | ||
|
||
setup :verify_on_exit! | ||
|
||
setup do | ||
client = Application.get_env(:tzdata, :http_client) | ||
Application.put_env(:tzdata, :http_client, Tzdata.HTTPClient.Mock) | ||
|
||
Application.put_env( | ||
:tzdata, | ||
:download_url, | ||
"https://data.iana.org/time-zones/tzdata-latest.tar.gz" | ||
) | ||
|
||
on_exit(fn -> | ||
Application.put_env(:tzdata, :http_client, client) | ||
:ok | ||
end) | ||
end | ||
|
||
describe "download_new/1" do | ||
test "when url not given, should download content from default url" do | ||
expect(Mock, :get, fn "https://data.iana.org/time-zones/tzdata-latest.tar.gz", | ||
_, | ||
[follow_redirect: true] -> | ||
{:ok, | ||
{200, [{"Last-Modified", "Wed, 21 Oct 2015 07:28:00 GMT"}], | ||
File.read!("test/tzdata_fixtures/tzdata2024a.tar.gz")}} | ||
end) | ||
|
||
assert {:ok, 451_270, "2024a", _new_dir_name, "Wed, 21 Oct 2015 07:28:00 GMT"} = | ||
Tzdata.DataLoader.download_new() | ||
end | ||
|
||
test "when url given, should download content from given url" do | ||
expect(Mock, :get, fn "https://data.iana.org/time-zones/tzdata2024a.tar.gz", _, _ -> | ||
{:ok, | ||
{200, [{"Last-Modified", "Wed, 21 Oct 2015 07:28:00 GMT"}], | ||
File.read!("test/tzdata_fixtures/tzdata2024a.tar.gz")}} | ||
end) | ||
|
||
assert {:ok, 451_270, "2024a", _new_dir_name, "Wed, 21 Oct 2015 07:28:00 GMT"} = | ||
Tzdata.DataLoader.download_new( | ||
"https://data.iana.org/time-zones/tzdata2024a.tar.gz" | ||
) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
ExUnit.start() | ||
|
||
Mox.defmock(Tzdata.HTTPClient.Mock, for: Tzdata.HTTPClient) |
Oops, something went wrong.