jaydoane commented on code in PR #4813:
URL: https://github.com/apache/couchdb/pull/4813#discussion_r1406526840
##########
src/config/test/config_tests.erl:
##########
@@ -115,6 +111,41 @@ handle_config_terminate(Self, Reason, {Pid, State}) ->
Pid ! {config_msg, {Self, Reason, State}},
ok.
+setup_ini(IniFiles) ->
+ Chain = [write_ini(F) || F <- IniFiles],
+ {Chain, setup(Chain)}.
+
+teardown_ini(_, {Chain, Apps}) ->
+ lists:foreach(
+ fun(Path) -> ok = file:delete(Path) end,
+ Chain
+ ),
+ teardown(Apps).
+
+write_ini(FileName) ->
+ Path = filename:join([?TEMPDIR, FileName]),
+ Data = io_lib:format("[section]\nfile = ~s\n", [FileName]),
+ ok = file:write_file(Path, Data),
+ Path.
+
+config_delete_reload_restart_test_() ->
+ {
+ "Test consistency after set, delete, reload, and restart",
+ foreachx,
+ fun setup_ini/1,
+ fun teardown_ini/2,
+ [
+ {
+ ["default.ini", "local.ini"],
+ fun non_persistent_set_delete_reload_restart/2
Review Comment:
Those tests originally did just use `foreach`, and the generated `.ini`
files were hardcoded in `setup_ini`. But then I was curious about whether
persistent `set` and `delete` variations would also write to an `.ini` file if
there was only one, so I changed it to `foreachx` in order to factor out the
config chain. Turns out that because of how `write_filename` is defined:
```erlang
WriteFile =
case IniFiles of
[_ | _] -> lists:last(IniFiles);
_ -> undefined
end,
```
that it does indeed write to a single `.ini` file configuration (further
evidence that `default.ini` is not a great name).
So maybe I should just change it back now that my experiment has concluded
there's no real edge case for just a single `.ini` config?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]