Skip to content

Commit

Permalink
Add an integration test for 'escaped values'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Aug 3, 2024
1 parent dbf2061 commit fec337f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/cuttlefish_integration_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,19 @@ tagged_string_test() ->
NewConfig = cuttlefish_generator:map(Schema, Conf),
?assertEqual({tagged, "e614d97599dab483f"}, proplists:get_value(tagged_key, proplists:get_value(cuttlefish, NewConfig))).

escaped_value_test() ->
Schema = cuttlefish_schema:files(["test/escaped_values.schema"]),

Conf1 = conf_parse:parse("escaped.value = 'e9238-7_49%#sod7'\n"),
Config1 = cuttlefish_generator:map(Schema, Conf1),
%% with escaping, the '#' character and everything that follows it is preserved
?assertEqual("e9238-7_49%#sod7", proplists:get_value(value, proplists:get_value(escaped, Config1))),

Conf2 = conf_parse:parse(<<"non_escaped.value = 557sd79238749%#sod7f9s87ee4\n">>),
Config2 = cuttlefish_generator:map(Schema, Conf2),
%% without escaping, everything after the '#' is cut off
?assertEqual("557sd79238749%", proplists:get_value(value, proplists:get_value(non_escaped, Config2))).

proplist_equals(Expected, Actual) ->
ExpectedKeys = lists:sort(proplists:get_keys(Expected)),
ActualKeys = lists:sort(proplists:get_keys(Actual)),
Expand Down
7 changes: 7 additions & 0 deletions test/escaped_values.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{mapping, "escaped.value", "escaped.value", [
{datatype, [string]}
]}.

{mapping, "non_escaped.value", "non_escaped.value", [
{datatype, [string]}
]}.

0 comments on commit fec337f

Please sign in to comment.