Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: erlang

otp_release:
- 18.1
- 18.0
- 17.5
- 21.1
- 20.3
- 19.3

sudo: false

Expand Down
2 changes: 1 addition & 1 deletion src/config_writer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ save_to_file({{Section, Key}, Value}, File) ->
Lines = re:split(OldFileContents, "\r\n|\n|\r|\032", [{return, list}]),

SectionLine = "[" ++ Section ++ "]",
{ok, Pattern} = re:compile(["^(", Key, "\\s*=)|\\[[a-zA-Z0-9\.\_-]*\\]"]),
{ok, Pattern} = re:compile(["^(\\Q", Key, "\\E\\s*=)|\\[[a-zA-Z0-9\.\_-]*\\]"]),

NewLines = process_file_lines(Lines, [], SectionLine, Pattern, Key, Value),
NewFileContents = reverse_and_add_newline(strip_empty_lines(NewLines), []),
Expand Down
19 changes: 19 additions & 0 deletions test/config_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,20 @@ config_notifier_behaviour_test_() ->
}.


config_key_has_regex_test_() ->
{
"Test key with regex can be compiled and written to file",
{
foreach,
fun setup/0,
fun teardown/1,
[
fun should_handle_regex_patterns_in_key/0
]
}
}.


config_access_right_test_() ->
{
"Test config file access right",
Expand All @@ -318,6 +332,11 @@ should_write_config_to_file() ->
?assertEqual(ok, config:set("admins", "foo", "500", true)).


should_handle_regex_patterns_in_key() ->
?assertEqual(ok, config:set("sect1", "pat||*", "true", true)),
?assertEqual([{"pat||*", "true"}], config:get("sect1")).


should_delete_config_from_file() ->
?assertEqual(ok, config:delete("admins", "foo", true)).

Expand Down