You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/12/04 21:09:52 UTC
[21/22] couch commit: updated
refs/heads/2491-refactor-couch-httpd-auth to 3e8286d
Expose and add helper for tests
In order to make them reusable in the chhtpd integration-tests.
Additionally adding a post and delete helper.
COUCHDB-2462
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/2a45cb03
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/2a45cb03
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/2a45cb03
Branch: refs/heads/2491-refactor-couch-httpd-auth
Commit: 2a45cb0325b72eb0910029bed5d2c38f784f68f9
Parents: 741a82d
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Sun Nov 30 03:13:36 2014 +0100
Committer: Robert Kowalski <ro...@kowalski.gd>
Committed: Mon Dec 1 21:22:43 2014 +0100
----------------------------------------------------------------------
src/test_request.erl | 81 ++++++++++++++++++++++++++++++++++++++++++++++
src/test_util.erl | 1 +
test/test_request.erl | 75 ------------------------------------------
3 files changed, 82 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/2a45cb03/src/test_request.erl
----------------------------------------------------------------------
diff --git a/src/test_request.erl b/src/test_request.erl
new file mode 100644
index 0000000..9693976
--- /dev/null
+++ b/src/test_request.erl
@@ -0,0 +1,81 @@
+% 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(test_request).
+
+-export([get/1, get/2, get/3]).
+-export([post/3]).
+-export([put/2, put/3]).
+-export([delete/1]).
+-export([options/1, options/2, options/3]).
+-export([request/3, request/4]).
+
+get(Url) ->
+ request(get, Url, []).
+
+get(Url, Headers) ->
+ request(get, Url, Headers).
+get(Url, Headers, Opts) ->
+ request(get, Url, Headers, [], Opts).
+
+post(Url, Headers, Body) ->
+ request(post, Url, Headers, Body).
+
+put(Url, Body) ->
+ request(put, Url, [], Body).
+
+put(Url, Headers, Body) ->
+ request(put, Url, Headers, Body).
+
+delete(Url) ->
+ request(delete, Url, []).
+
+options(Url) ->
+ request(options, Url, []).
+
+options(Url, Headers) ->
+ request(options, Url, Headers).
+
+options(Url, Headers, Opts) ->
+ request(options, Url, Headers, [], Opts).
+
+
+request(Method, Url, Headers) ->
+ request(Method, Url, Headers, []).
+
+request(Method, Url, Headers, Body) ->
+ request(Method, Url, Headers, Body, [], 3).
+
+request(Method, Url, Headers, Body, Opts) ->
+ request(Method, Url, Headers, Body, Opts, 3).
+
+request(_Method, _Url, _Headers, _Body, _Opts, 0) ->
+ {error, request_failed};
+request(Method, Url, Headers, Body, Opts, N) ->
+ case code:is_loaded(ibrowse) of
+ false ->
+ {ok, _} = ibrowse:start();
+ _ ->
+ ok
+ end,
+ case ibrowse:send_req(Url, Headers, Method, Body, Opts) of
+ {ok, Code0, RespHeaders, RespBody0} ->
+ Code = list_to_integer(Code0),
+ RespBody = iolist_to_binary(RespBody0),
+ {ok, Code, RespHeaders, RespBody};
+ {error, {'EXIT', {normal, _}}} ->
+ % Connection closed right after a successful request that
+ % used the same connection.
+ request(Method, Url, Headers, Body, N - 1);
+ Error ->
+ Error
+ end.
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/2a45cb03/src/test_util.erl
----------------------------------------------------------------------
diff --git a/src/test_util.erl b/src/test_util.erl
index 3f90330..9340d36 100644
--- a/src/test_util.erl
+++ b/src/test_util.erl
@@ -20,6 +20,7 @@
-export([request/3, request/4]).
-export([start_couch/0, start_couch/1, stop_couch/0, stop_couch/1]).
-export([start_config/1, stop_config/1]).
+-export([start_applications/1]).
srcdir() ->
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/2a45cb03/test/test_request.erl
----------------------------------------------------------------------
diff --git a/test/test_request.erl b/test/test_request.erl
deleted file mode 100644
index 68e4956..0000000
--- a/test/test_request.erl
+++ /dev/null
@@ -1,75 +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(test_request).
-
--export([get/1, get/2, get/3]).
--export([put/2, put/3]).
--export([options/1, options/2, options/3]).
--export([request/3, request/4]).
-
-get(Url) ->
- request(get, Url, []).
-
-get(Url, Headers) ->
- request(get, Url, Headers).
-get(Url, Headers, Opts) ->
- request(get, Url, Headers, [], Opts).
-
-
-put(Url, Body) ->
- request(put, Url, [], Body).
-
-put(Url, Headers, Body) ->
- request(put, Url, Headers, Body).
-
-
-options(Url) ->
- request(options, Url, []).
-
-options(Url, Headers) ->
- request(options, Url, Headers).
-
-options(Url, Headers, Opts) ->
- request(options, Url, Headers, [], Opts).
-
-
-request(Method, Url, Headers) ->
- request(Method, Url, Headers, []).
-
-request(Method, Url, Headers, Body) ->
- request(Method, Url, Headers, Body, [], 3).
-
-request(Method, Url, Headers, Body, Opts) ->
- request(Method, Url, Headers, Body, Opts, 3).
-
-request(_Method, _Url, _Headers, _Body, _Opts, 0) ->
- {error, request_failed};
-request(Method, Url, Headers, Body, Opts, N) ->
- case code:is_loaded(ibrowse) of
- false ->
- {ok, _} = ibrowse:start();
- _ ->
- ok
- end,
- case ibrowse:send_req(Url, Headers, Method, Body, Opts) of
- {ok, Code0, RespHeaders, RespBody0} ->
- Code = list_to_integer(Code0),
- RespBody = iolist_to_binary(RespBody0),
- {ok, Code, RespHeaders, RespBody};
- {error, {'EXIT', {normal, _}}} ->
- % Connection closed right after a successful request that
- % used the same connection.
- request(Method, Url, Headers, Body, N - 1);
- Error ->
- Error
- end.