summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Doane <jay.s.doane@gmail.com>2017-06-13 00:51:55 -0700
committerNick Vatamaniuc <nickva@users.noreply.github.com>2017-06-16 01:59:06 -0400
commit2269b644770a9a53d4571ced8a9e996c95d30979 (patch)
tree7067e5f0a5f138634d0f8f5291044209f9cc2560
parent6df7553d3d48b479520892ac1184a95ed0cfbdf8 (diff)
downloadcouchdb-2269b644770a9a53d4571ced8a9e996c95d30979.tar.gz
Factor attachment_doc/0
-rw-r--r--src/chttpd/test/chttpd_db_test.erl35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/chttpd/test/chttpd_db_test.erl b/src/chttpd/test/chttpd_db_test.erl
index a739a3d15..0ff415bd0 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)}
+ ]}
+ }]}}
+ ]}.