summaryrefslogtreecommitdiff
path: root/test/etap
diff options
context:
space:
mode:
Diffstat (limited to 'test/etap')
-rwxr-xr-xtest/etap/030-doc-from-json.t21
-rwxr-xr-xtest/etap/031-doc-to-json.t42
2 files changed, 47 insertions, 16 deletions
diff --git a/test/etap/030-doc-from-json.t b/test/etap/030-doc-from-json.t
index 2bfdfdc5..241aee40 100755
--- a/test/etap/030-doc-from-json.t
+++ b/test/etap/030-doc-from-json.t
@@ -16,7 +16,8 @@
%% XXX: Figure out how to -include("couch_db.hrl")
-record(doc, {id= <<"">>, revs={0, []}, body={[]},
- attachments=[], deleted=false, meta=[]}).
+ atts=[], deleted=false, meta=[]}).
+-record(att, {name, type, len, md5= <<>>, revpos=0, data}).
main(_) ->
code:add_pathz("src/couchdb"),
@@ -79,11 +80,19 @@ test_from_json_success() ->
{<<"content_type">>, <<"application/pgp-signature">>}
]}}
]}}]},
- #doc{attachments=[
- {<<"my_attachment.fu">>,
- {stub, <<"application/awesome">>, 45}},
- {<<"noahs_private_key.gpg">>,
- {<<"application/pgp-signature">>, <<"I have a pet fish!">>}}
+ #doc{atts=[
+ #att{
+ name = <<"my_attachment.fu">>,
+ data = stub,
+ type = <<"application/awesome">>,
+ len = 45
+ },
+ #att{
+ name = <<"noahs_private_key.gpg">>,
+ data = <<"I have a pet fish!">>,
+ type = <<"application/pgp-signature">>,
+ len = 18
+ }
]},
"Attachments are parsed correctly."
},
diff --git a/test/etap/031-doc-to-json.t b/test/etap/031-doc-to-json.t
index 1bf49d6b..7d2ca065 100755
--- a/test/etap/031-doc-to-json.t
+++ b/test/etap/031-doc-to-json.t
@@ -16,7 +16,8 @@
%% XXX: Figure out how to -include("couch_db.hrl")
-record(doc, {id= <<"">>, revs={0, []}, body={[]},
- attachments=[], deleted=false, meta=[]}).
+ atts=[], deleted=false, meta=[]}).
+-record(att, {name, type, len, md5= <<>>, revpos=0, data}).
main(_) ->
code:add_pathz("src/couchdb"),
@@ -109,9 +110,18 @@ test_to_json_success() ->
"_deleted_conflicsts is added as an array of strings."
},
{
- #doc{attachments=[
- {<<"big.xml">>, {<<"xml/sucks">>, {fun() -> ok end, 400}}},
- {<<"fast.json">>, {<<"json/ftw">>, <<"{\"so\": \"there!\"}">>}}
+ #doc{atts=[
+ #att{
+ name = <<"big.xml">>,
+ type = <<"xml/sucks">>,
+ data = fun() -> ok end,
+ len = 400
+ },
+ #att{
+ name = <<"fast.json">>,
+ type = <<"json/ftw">>,
+ data = <<"{\"so\": \"there!\"}">>
+ }
]},
{[
{<<"_id">>, <<>>},
@@ -119,12 +129,14 @@ test_to_json_success() ->
{<<"big.xml">>, {[
{<<"stub">>, true},
{<<"content_type">>, <<"xml/sucks">>},
- {<<"length">>, 400}
+ {<<"length">>, 400},
+ {<<"revpos">>, 0}
]}},
{<<"fast.json">>, {[
{<<"stub">>, true},
{<<"content_type">>, <<"json/ftw">>},
- {<<"length">>, 16}
+ {<<"length">>, 16},
+ {<<"revpos">>, 0}
]}}
]}}
]},
@@ -132,20 +144,30 @@ test_to_json_success() ->
},
{
[attachments],
- #doc{attachments=[
- {<<"stuff.txt">>,
- {<<"text/plain">>, {fun() -> <<"diet pepsi">> end, 10}}},
- {<<"food.now">>, {<<"application/food">>, <<"sammich">>}}
+ #doc{atts=[
+ #att{
+ name = <<"stuff.txt">>,
+ type = <<"text/plain">>,
+ data = fun() -> <<"diet pepsi">> end,
+ len = 10
+ },
+ #att{
+ name = <<"food.now">>,
+ type = <<"application/food">>,
+ data = <<"sammich">>
+ }
]},
{[
{<<"_id">>, <<>>},
{<<"_attachments">>, {[
{<<"stuff.txt">>, {[
{<<"content_type">>, <<"text/plain">>},
+ {<<"revpos">>, 0},
{<<"data">>, <<"ZGlldCBwZXBzaQ==">>}
]}},
{<<"food.now">>, {[
{<<"content_type">>, <<"application/food">>},
+ {<<"revpos">>, 0},
{<<"data">>, <<"c2FtbWljaA==">>}
]}}
]}}