jaydoane commented on code in PR #4813:
URL: https://github.com/apache/couchdb/pull/4813#discussion_r1406491018
##########
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:
I tried adding these lines to `couch_eunit.hrl`:
```erlang
-ifndef(TDEF_FEX).
-define(TDEF_FEX(Name), fun(R, X) -> {atom_to_list(Name), ?_test(Name(R,
X))} end).
-define(TDEF_FEX(Name, Timeout), fun(R, X) -> {atom_to_list(Name), {timeout,
Timeout, ?_test(Name(R, X))}} end).
-endif.
```
and rewrote these new tests to use it.
However, as I worked on converting the _rest_ of this file to use `TDEF_FEX`
in the `foreachx` tests, I realized it might take a bit more effort with tests
like e.g. `should_notify_on_config_reload` which don't seem to lend themselves
to a simple conversion. I will continue to ponder the best approach, and would
welcome advice.
--
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]