-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace "jsx" with built-in "json" module (#163)
Co-authored-by: Ivan Bakalov <ivan.bakalov@dnsimple.com>
- Loading branch information
1 parent
324ab10
commit 08f1a8a
Showing
10 changed files
with
98 additions
and
54 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
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
crypto, | ||
lager, | ||
dns_erlang, | ||
jsx, | ||
ssl, | ||
mnesia, | ||
bear, | ||
|
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,35 @@ | ||
-module(erldns_storage_test). | ||
|
||
-feature(maybe_expr, enable). | ||
|
||
-include_lib("dns_erlang/include/dns.hrl"). | ||
-include_lib("erldns/include/erldns.hrl"). | ||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
-define(TEST_MODULE, erldns_storage). | ||
|
||
load_zones_with_existing_file_test() -> | ||
{ok, Pid} = erldns_zone_parser:start_link(), | ||
erldns_storage:create(zones), | ||
erldns_storage:create(zone_records_typed), | ||
Filename = filename:join(tmp_dir(), "zones.json"), | ||
|
||
ok = file:write_file( | ||
Filename, | ||
<<"[{\"name\": \"example.com\", \"records\": [{\"name\": \"example.com\", \"type\": \"SOA\", \"data\": {\"mname\": \"ns1.example.com\", \"rname\": \"ahu.example.com\", \"serial\": 2000081501, \"refresh\": 28800, \"retry\": 7200, \"expire\": 604800, \"minimum\": 86400}, \"ttl\": 100000}]}]">> | ||
), | ||
|
||
?assertMatch({ok, 1}, ?TEST_MODULE:load_zones(Filename)), | ||
gen_server:stop(Pid). | ||
|
||
%% Helpers | ||
|
||
tmp_dir() -> | ||
maybe | ||
false ?= os:getenv("TMPDIR"), | ||
false ?= os:getenv("TEMP"), | ||
false ?= os:getenv("TMP"), | ||
"/tmp" | ||
else | ||
Dir -> Dir | ||
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-module(erldns_zone_encoder_test). | ||
|
||
-feature(maybe_expr, enable). | ||
|
||
-include_lib("dns_erlang/include/dns.hrl"). | ||
-include_lib("erldns/include/erldns.hrl"). | ||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
-define(TEST_MODULE, erldns_storage). | ||
|
||
zone_meta_to_json_with_valid_zone_test() -> | ||
{ok, Pid} = erldns_zone_parser:start_link(), | ||
erldns_storage:create(zones), | ||
erldns_storage:create(zone_records_typed), | ||
|
||
Z = #zone{ | ||
name = <<"example.com">>, | ||
authority = [#dns_rr{name = <<"example.com">>, type = ?DNS_TYPE_SOA}] | ||
}, | ||
|
||
JSON = erldns_zone_encoder:zone_meta_to_json(Z), | ||
?assert(is_binary(JSON)), | ||
|
||
#{ | ||
<<"erldns">> := #{ | ||
<<"zone">> := #{ | ||
<<"name">> := <<"example.com">>, | ||
<<"version">> := _, | ||
<<"records_count">> := _ | ||
} | ||
} | ||
} = json:decode(JSON), | ||
|
||
gen_server:stop(Pid). |