Refactor test suite for httpd endpoints#65
Conversation
Split out common parts into util module so we can reuse test suite. The util module could be used for testing: - endpoints defined in other applications - overridden endpoints COUCHDB-2789
COUCHDB-2789
|
This PR depends on apache/couchdb-couch-epi#6 |
There was a problem hiding this comment.
I wonder if there is a way to not have this list duplicate definitions in chttpd_chttpd_handlers...at least for handlers.
There was a problem hiding this comment.
It would be trivial with elixir macro :-).
On a serious note though few ideas to consider (crazy ones as well).
- Use https://github.com/richcarl/merl to generate
handlersclauses - Extract the info from beam chunks somehow
- Use macro somehow (very problematic with erlang text based preprocessor).
- Define handlers as it is done in tests (performance impact).
- Require something like
endpoints(db_handler) -> [<<"_view_cleanup">>, <<"compact">>]in<app>_httpd_handlers.erl
There was a problem hiding this comment.
Number 5) Is the simplest one
There was a problem hiding this comment.
On a side note. I am also thinking rather it would be better to place tests in <app>_httpd_handlers.erl itself.
There was a problem hiding this comment.
I'm actually quite like option 5)
There was a problem hiding this comment.
I am also thinking rather it would be better to place tests in _httpd_handlers.erl itself.
+1 - this will at least help to not miss the tests if you're going to modify handlers. My point here was about to not fall into situation, when you change/update <app>_httpd_handlers.erl and not update the tests (they may eventually stay green after) and imho this should help a bit.
It would be trivial with elixir macro :-).
I think use elixir for testing is not a bad idea at all. They have quite friendly and powerful tools for that. But not today (:
COUCHDB-2789
COUCHDB-2789
|
I did rework the structure of the PR a little bit. |
|
I think it's good and helpful for introspection proposes. And one more step closer to the same behavior as |
|
stale PR |
Split out common parts into util module so we can reuse test suite.
The util module could be used for testing:
COUCHDB-2789