You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2017/06/16 05:59:10 UTC

[couchdb] 01/02: Factor attachment_doc/0

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 2269b644770a9a53d4571ced8a9e996c95d30979
Author: Jay Doane <ja...@gmail.com>
AuthorDate: Tue Jun 13 00:51:55 2017 -0700

    Factor attachment_doc/0
---
 src/chttpd/test/chttpd_db_test.erl | 35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/src/chttpd/test/chttpd_db_test.erl b/src/chttpd/test/chttpd_db_test.erl
index a739a3d..0ff415b 100644
--- a/src/chttpd/test/chttpd_db_test.erl
+++ b/src/chttpd/test/chttpd_db_test.erl
@@ -134,19 +134,10 @@ should_return_404_for_delete_att_on_notadoc(Url) ->
 
 should_return_409_for_del_att_without_rev(Url) ->
     ?_test(begin
-        {ok, Data} = file:read_file(?FIXTURE_TXT),
-        Doc = {[
-            {<<"_attachments">>, {[
-                {<<"file.erl">>, {[
-                    {<<"content_type">>, <<"text/plain">>},
-                    {<<"data">>, base64:encode(Data)}
-                ]}
-            }]}}
-        ]},
         {ok, RC, _, _} = test_request:put(
             Url ++ "/testdoc3",
             [?CONTENT_JSON, ?AUTH],
-            jiffy:encode(Doc)
+            jiffy:encode(attachment_doc())
         ),
         ?assertEqual(201, RC),
 
@@ -158,21 +149,13 @@ should_return_409_for_del_att_without_rev(Url) ->
         ?assertEqual(409, RC1)
     end).
 
+
 should_return_200_for_del_att_with_rev(Url) ->
   ?_test(begin
-      {ok, Data} = file:read_file(?FIXTURE_TXT),
-      Doc = {[
-          {<<"_attachments">>, {[
-              {<<"file.erl">>, {[
-                  {<<"content_type">>, <<"text/plain">>},
-                  {<<"data">>, base64:encode(Data)}
-              ]}
-          }]}}
-      ]},
       {ok, RC, _Headers, RespBody} = test_request:put(
           Url ++ "/testdoc4",
           [?CONTENT_JSON, ?AUTH],
-          jiffy:encode(Doc)
+          jiffy:encode(attachment_doc())
       ),
       ?assertEqual(201, RC),
 
@@ -186,3 +169,15 @@ should_return_200_for_del_att_with_rev(Url) ->
       ),
       ?assertEqual(200, RC1)
     end).
+
+
+attachment_doc() ->
+    {ok, Data} = file:read_file(?FIXTURE_TXT),
+    {[
+        {<<"_attachments">>, {[
+            {<<"file.erl">>, {[
+                {<<"content_type">>, <<"text/plain">>},
+                {<<"data">>, base64:encode(Data)}
+            ]}
+        }]}}
+    ]}.

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.