couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [05/25] couch commit: updated refs/heads/master to 92598cd
Date Thu, 15 Oct 2015 16:35:39 GMT
Add test case for doc_from_multi_part_stream


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/b6961c50
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/b6961c50
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/b6961c50

Branch: refs/heads/master
Commit: b6961c5085422d118e0f797ba1c0247f2b2a751f
Parents: f7b9dae
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Thu Nov 27 14:16:20 2014 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Wed May 6 06:55:58 2015 -0700

----------------------------------------------------------------------
 test/couch_doc_tests.erl     | 18 ++++++++++++++++++
 test/fixtures/multipart.http | 13 +++++++++++++
 2 files changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/b6961c50/test/couch_doc_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_doc_tests.erl b/test/couch_doc_tests.erl
index ca944dc..c9d32a8 100644
--- a/test/couch_doc_tests.erl
+++ b/test/couch_doc_tests.erl
@@ -13,10 +13,28 @@
 -module(couch_doc_tests).
 
 -include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch/include/couch_db.hrl").
 
 
+-define(REQUEST_FIXTURE,
+    filename:join([?FIXTURESDIR, "multipart.http"])).
+
 parse_rev_test() ->
     ?assertEqual({1, <<"123">>}, couch_doc:parse_rev("1-123")),
     ?assertEqual({1, <<"123">>}, couch_doc:parse_rev(<<"1-123">>)),
     ?assertException(throw, {bad_request, _}, couch_doc:parse_rev("1f-123")),
     ?assertException(throw, {bad_request, _}, couch_doc:parse_rev("bar")).
+
+doc_from_multi_part_stream_test() ->
+    ContentType = "multipart/related;boundary=multipart_related_boundary~~~~~~~~~~~~~~~~~~~~",
+    DataFun = fun() -> request(start) end,
+
+    {ok, #doc{id = <<"doc0">>, atts = [_]} = Doc, _Fun, _Parser} =
+        couch_httpd_multipart:doc_from_multi_part_stream(ContentType, DataFun),
+    ok.
+
+request(start) ->
+    {ok, Doc} = file:read_file(?REQUEST_FIXTURE),
+    {Doc, fun() -> request(stop) end};
+request(stop) ->
+    {"", fun() -> request(stop) end}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/b6961c50/test/fixtures/multipart.http
----------------------------------------------------------------------
diff --git a/test/fixtures/multipart.http b/test/fixtures/multipart.http
new file mode 100644
index 0000000..fe9f271
--- /dev/null
+++ b/test/fixtures/multipart.http
@@ -0,0 +1,13 @@
+{
+ "_id": "our document goes here"
+}
+
+--multipart_related_boundary~~~~~~~~~~~~~~~~~~~~
+Content-Type: application/json
+
+{"value":0,"_id":"doc0","_rev":"1-7e97409c987eac3a99385a17ad4cbabe","_attachments":{"plus1":{"stub":false,"follows":true,"content_type":"application/json","length":14}},".cache":{"plus1":{"timestamp":"2012-08-13T13:59:27.826Z"}}}
+--multipart_related_boundary~~~~~~~~~~~~~~~~~~~~
+
+{"value":"01"}
+--multipart_related_boundary~~~~~~~~~~~~~~~~~~~~--
+


Mime
View raw message