Repository: couchdb-mango Updated Branches: refs/heads/master 893028883 -> f6d4901bc
Return ddoc id and index name We return the ddoc id and index name for easier deletion from the dashboard. We don't return the full design doc because we want to hide that abstraction of dealing with design docs from the user. FIXES COUCHDB-2645 Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/f6d4901b Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/f6d4901b Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/f6d4901b Branch: refs/heads/master Commit: f6d4901bc5717c17397d8baec27e3501d92c1fdb Parents: 8930288 Author: Tony Sun <tony....@cloudant.com> Authored: Wed Mar 25 16:29:31 2015 -0700 Committer: Tony Sun <tony....@cloudant.com> Committed: Tue Mar 31 08:50:48 2015 -0700 ---------------------------------------------------------------------- src/mango_httpd.erl | 5 ++++- test/mango.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/f6d4901b/src/mango_httpd.erl ---------------------------------------------------------------------- diff --git a/src/mango_httpd.erl b/src/mango_httpd.erl index 2588a23..28a1578 100644 --- a/src/mango_httpd.erl +++ b/src/mango_httpd.erl @@ -20,6 +20,7 @@ -include_lib("couch/include/couch_db.hrl"). -include("mango.hrl"). +-include("mango_idx.hrl"). handle_req(#httpd{} = Req, Db0) -> @@ -58,6 +59,8 @@ handle_index_req(#httpd{method='POST', path_parts=[_, _]}=Req, Db) -> {ok, Idx0} = mango_idx:new(Db, Opts), {ok, Idx} = mango_idx:validate(Idx0), {ok, DDoc} = mango_util:load_ddoc(Db, mango_idx:ddoc(Idx)), + Id = Idx#idx.ddoc, + Name = Idx#idx.name, Status = case mango_idx:add(DDoc, Idx) of {ok, DDoc} -> <<"exists">>; @@ -75,7 +78,7 @@ handle_index_req(#httpd{method='POST', path_parts=[_, _]}=Req, Db) -> ?MANGO_ERROR(error_saving_ddoc) end end, - chttpd:send_json(Req, {[{result, Status}]}); + chttpd:send_json(Req, {[{result, Status}, {id, Id}, {name, Name}]}); handle_index_req(#httpd{method='DELETE', path_parts=[A, B, <<"_design">>, DDocId0, Type, Name]}=Req, Db) -> http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/f6d4901b/test/mango.py ---------------------------------------------------------------------- diff --git a/test/mango.py b/test/mango.py index 79545e1..57dfffb 100644 --- a/test/mango.py +++ b/test/mango.py @@ -96,6 +96,8 @@ class Database(object): body = json.dumps(body) r = self.sess.post(self.path("_index"), data=body) r.raise_for_status() + assert r.json()["id"] is not None + assert r.json()["name"] is not None return r.json()["result"] == "created" def create_text_index(self, analyzer=None, selector=None, idx_type="text", @@ -176,7 +178,7 @@ class DbPerClass(unittest.TestCase): @classmethod def setUpClass(klass): - klass.db = Database("127.0.0.1", "5984", random_db_name()) + klass.db = Database("127.0.0.1", "15984", random_db_name()) klass.db.create(q=1, n=3) def setUp(self):