From d0316873598f3eddc7ebd3aa0d8e78ca2dcded6f Mon Sep 17 00:00:00 2001 From: ILYA Khlopotov Date: Tue, 25 Aug 2015 09:18:55 -0700 Subject: [PATCH 1/2] Add test suite for http endpoints COUCHDB-2789 --- test/setup_httpd_handlers_tests.erl | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/setup_httpd_handlers_tests.erl diff --git a/test/setup_httpd_handlers_tests.erl b/test/setup_httpd_handlers_tests.erl new file mode 100644 index 0000000..346af81 --- /dev/null +++ b/test/setup_httpd_handlers_tests.erl @@ -0,0 +1,30 @@ +% 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(setup_httpd_handlers_tests). + +-export([handlers/1]). + +-include_lib("couch/include/couch_eunit.hrl"). + +handlers(url_handler) -> + [ + {<<"_cluster_setup">>, setup_httpd, handle_setup_req} + ]; +handlers(db_handler) -> + []; +handlers(design_handler) -> + []. + +setup_endpoints_test_() -> + Apps = [couch_epi, setup], + chttpd_httpd_handlers_test_util:endpoints_test(setup, ?MODULE, Apps). From 8cd47ef756138043a8433d38f469ee56d62a7c02 Mon Sep 17 00:00:00 2001 From: ILYA Khlopotov Date: Thu, 27 Aug 2015 08:01:34 -0700 Subject: [PATCH 2/2] Add an ability to introspect endpoints and tests COUCHDB-2789 --- src/setup_httpd_handlers.erl | 20 ++++++++++++++++++- test/setup_httpd_handlers_tests.erl | 30 ----------------------------- 2 files changed, 19 insertions(+), 31 deletions(-) delete mode 100644 test/setup_httpd_handlers_tests.erl diff --git a/src/setup_httpd_handlers.erl b/src/setup_httpd_handlers.erl index 994c217..0261bb7 100644 --- a/src/setup_httpd_handlers.erl +++ b/src/setup_httpd_handlers.erl @@ -12,7 +12,7 @@ -module(setup_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(<<"_cluster_setup">>) -> fun setup_httpd:handle_setup_req/1; url_handler(_) -> no_match. @@ -20,3 +20,21 @@ url_handler(_) -> no_match. db_handler(_) -> no_match. design_handler(_) -> no_match. + +endpoints(url_handler) -> + [ + <<"_cluster_setup">> + ]; +endpoints(db_handler) -> + []; +endpoints(design_handler) -> + []. + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + +setup_endpoints_test_() -> + Apps = [couch_epi, setup], + chttpd_httpd_handlers_test_util:endpoints_test(setup, ?MODULE, Apps). + +-endif. diff --git a/test/setup_httpd_handlers_tests.erl b/test/setup_httpd_handlers_tests.erl deleted file mode 100644 index 346af81..0000000 --- a/test/setup_httpd_handlers_tests.erl +++ /dev/null @@ -1,30 +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(setup_httpd_handlers_tests). - --export([handlers/1]). - --include_lib("couch/include/couch_eunit.hrl"). - -handlers(url_handler) -> - [ - {<<"_cluster_setup">>, setup_httpd, handle_setup_req} - ]; -handlers(db_handler) -> - []; -handlers(design_handler) -> - []. - -setup_endpoints_test_() -> - Apps = [couch_epi, setup], - chttpd_httpd_handlers_test_util:endpoints_test(setup, ?MODULE, Apps).