From 909c68f4aab61005507b1a344a8fb63c80463a14 Mon Sep 17 00:00:00 2001 From: ILYA Khlopotov Date: Tue, 25 Aug 2015 09:13:43 -0700 Subject: [PATCH 1/2] Add test suite for http endpoints COUCHDB-2789 --- test/mem3_httpd_handlers_tests.erl | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/mem3_httpd_handlers_tests.erl diff --git a/test/mem3_httpd_handlers_tests.erl b/test/mem3_httpd_handlers_tests.erl new file mode 100644 index 0000000..9c726ef --- /dev/null +++ b/test/mem3_httpd_handlers_tests.erl @@ -0,0 +1,32 @@ +% Licensed under the Apache License, Version 2.0 (the "License"); you may not +% use this file except in compliance with the License. You may obtain a copy of +% the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +% License for the specific language governing permissions and limitations under +% the License. + +-module(mem3_httpd_handlers_tests). + +-export([handlers/1]). + +-include_lib("couch/include/couch_eunit.hrl"). + +handlers(url_handler) -> + [ + {<<"_membership">>, mem3_httpd, handle_membership_req} + ]; +handlers(db_handler) -> + [ + {<<"_shards">>, mem3_httpd, handle_shards_req} + ]; +handlers(design_handler) -> + []. + +mem3_endpoints_test_() -> + Apps = [couch_epi, mem3], + chttpd_httpd_handlers_test_util:endpoints_test(mem3, ?MODULE, Apps). From e2018c48f77416c2051f3a1aa8c0654f2a37b77b Mon Sep 17 00:00:00 2001 From: ILYA Khlopotov Date: Thu, 27 Aug 2015 08:17:22 -0700 Subject: [PATCH 2/2] Add an ability to introspect endpoints and tests COUCHDB-2789 --- src/mem3_httpd_handlers.erl | 22 +++++++++++++++++++- test/mem3_httpd_handlers_tests.erl | 32 ------------------------------ 2 files changed, 21 insertions(+), 33 deletions(-) delete mode 100644 test/mem3_httpd_handlers_tests.erl diff --git a/src/mem3_httpd_handlers.erl b/src/mem3_httpd_handlers.erl index d8e138c..af0b069 100644 --- a/src/mem3_httpd_handlers.erl +++ b/src/mem3_httpd_handlers.erl @@ -12,7 +12,7 @@ -module(mem3_httpd_handlers). --export([url_handler/1, db_handler/1, design_handler/1]). +-export([url_handler/1, db_handler/1, design_handler/1, endpoints/1]). url_handler(<<"_membership">>) -> fun mem3_httpd:handle_membership_req/1; url_handler(_) -> no_match. @@ -21,3 +21,23 @@ db_handler(<<"_shards">>) -> fun mem3_httpd:handle_shards_req/2; db_handler(_) -> no_match. design_handler(_) -> no_match. + +endpoints(url_handler) -> + [ + <<"_membership">> + ]; +endpoints(db_handler) -> + [ + <<"_shards">> + ]; +endpoints(design_handler) -> + []. + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + +mem3_endpoints_test_() -> + Apps = [couch_epi, mem3], + chttpd_httpd_handlers_test_util:endpoints_test(mem3, ?MODULE, Apps). + +-endif. diff --git a/test/mem3_httpd_handlers_tests.erl b/test/mem3_httpd_handlers_tests.erl deleted file mode 100644 index 9c726ef..0000000 --- a/test/mem3_httpd_handlers_tests.erl +++ /dev/null @@ -1,32 +0,0 @@ -% Licensed under the Apache License, Version 2.0 (the "License"); you may not -% use this file except in compliance with the License. You may obtain a copy of -% the License at -% -% http://www.apache.org/licenses/LICENSE-2.0 -% -% Unless required by applicable law or agreed to in writing, software -% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -% License for the specific language governing permissions and limitations under -% the License. - --module(mem3_httpd_handlers_tests). - --export([handlers/1]). - --include_lib("couch/include/couch_eunit.hrl"). - -handlers(url_handler) -> - [ - {<<"_membership">>, mem3_httpd, handle_membership_req} - ]; -handlers(db_handler) -> - [ - {<<"_shards">>, mem3_httpd, handle_shards_req} - ]; -handlers(design_handler) -> - []. - -mem3_endpoints_test_() -> - Apps = [couch_epi, mem3], - chttpd_httpd_handlers_test_util:endpoints_test(mem3, ?MODULE, Apps).