summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBenoit Chesneau <benoitc@apache.org>2010-03-01 14:57:28 +0000
committerBenoit Chesneau <benoitc@apache.org>2010-03-01 14:57:28 +0000
commit14bc90f931430c7cc3bf2af3f09874445dac7d29 (patch)
treeec13ad9af31afa35c212bd5604bbed7da64b8384 /test
parent7be616679cefe6850e9ba7ab0d46b5a9880e5fae (diff)
fix issue COUCHDB-678 applying patch from Filipe Manana.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@917553 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rwxr-xr-xtest/etap/160-vhosts.t31
1 files changed, 28 insertions, 3 deletions
diff --git a/test/etap/160-vhosts.t b/test/etap/160-vhosts.t
index fa61cabf..64c51554 100755
--- a/test/etap/160-vhosts.t
+++ b/test/etap/160-vhosts.t
@@ -35,8 +35,15 @@
conn = nil
}).
+-record(user_ctx, {
+ name = null,
+ roles = [],
+ handler
+}).
+
server() -> "http://127.0.0.1:5984/".
dbname() -> "etap-test-db".
+admin_user_ctx() -> {user_ctx, #user_ctx{roles=[<<"_admin">>]}}.
config_files() ->
lists:map(fun test_util:build_file/1, [
@@ -47,7 +54,7 @@ config_files() ->
main(_) ->
test_util:init_code_path(),
- etap:plan(2),
+ etap:plan(3),
case (catch test()) of
ok ->
etap:end_tests();
@@ -62,14 +69,22 @@ test() ->
ibrowse:start(),
crypto:start(),
- couch_server:delete(list_to_binary(dbname()), []),
- {ok, Db} = couch_db:create(list_to_binary(dbname()), []),
+ couch_server:delete(list_to_binary(dbname()), [admin_user_ctx()]),
+ {ok, Db} = couch_db:create(list_to_binary(dbname()), [admin_user_ctx()]),
+
+ Doc = couch_doc:from_json_obj({[
+ {<<"_id">>, <<"doc1">>},
+ {<<"value">>, 666}
+ ]}),
+ {ok, _} = couch_db:update_docs(Db, [Doc]),
+ couch_db:ensure_full_commit(Db),
%% end boilerplate, start test
couch_config:set("vhosts", "example.com", "/etap-test-db", false),
test_regular_request(),
test_vhost_request(),
+ test_vhost_request_with_qs(),
%% restart boilerplate
couch_db:close(Db),
@@ -94,3 +109,13 @@ test_vhost_request() ->
etap:is(true, true, "should return database info");
_Else -> false
end.
+
+test_vhost_request_with_qs() ->
+ Url = server() ++ "doc1?revs_info=true",
+ case ibrowse:send_req(Url, [], get, [], [{host_header, "example.com"}]) of
+ {ok, _, _, Body} ->
+ {JsonProps} = couch_util:json_decode(Body),
+ HasRevsInfo = proplists:is_defined(<<"_revs_info">>, JsonProps),
+ etap:is(HasRevsInfo, true, "should return _revs_info");
+ _Else -> false
+ end.