diff options
Diffstat (limited to 'src/couch_replicator/test/eunit/couch_replicator_test_helper.erl')
-rw-r--r-- | src/couch_replicator/test/eunit/couch_replicator_test_helper.erl | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/src/couch_replicator/test/eunit/couch_replicator_test_helper.erl b/src/couch_replicator/test/eunit/couch_replicator_test_helper.erl index fd0409164..4044e7c72 100644 --- a/src/couch_replicator/test/eunit/couch_replicator_test_helper.erl +++ b/src/couch_replicator/test/eunit/couch_replicator_test_helper.erl @@ -13,11 +13,9 @@ replicate/2 ]). - compare_dbs(Source, Target) -> compare_dbs(Source, Target, []). - compare_dbs(Source, Target, ExceptIds) -> {ok, SourceDb} = couch_db:open_int(Source, []), {ok, TargetDb} = couch_db:open_int(Target, []), @@ -39,13 +37,14 @@ compare_dbs(Source, Target, ExceptIds) -> ok = couch_db:close(SourceDb), ok = couch_db:close(TargetDb). - compare_docs(Doc1, Doc2) -> ?assertEqual(Doc1#doc.body, Doc2#doc.body), #doc{atts = Atts1} = Doc1, #doc{atts = Atts2} = Doc2, - ?assertEqual(lists:sort([couch_att:fetch(name, Att) || Att <- Atts1]), - lists:sort([couch_att:fetch(name, Att) || Att <- Atts2])), + ?assertEqual( + lists:sort([couch_att:fetch(name, Att) || Att <- Atts1]), + lists:sort([couch_att:fetch(name, Att) || Att <- Atts2]) + ), FunCompareAtts = fun(Att) -> AttName = couch_att:fetch(name, Att), {ok, AttTarget} = find_att(Atts2, AttName), @@ -67,18 +66,25 @@ compare_docs(Doc1, Doc2) -> ?assert(is_integer(couch_att:fetch(att_len, Att))), ?assert(is_integer(couch_att:fetch(disk_len, AttTarget))), ?assert(is_integer(couch_att:fetch(att_len, AttTarget))), - ?assertEqual(couch_att:fetch(disk_len, Att), - couch_att:fetch(disk_len, AttTarget)), - ?assertEqual(couch_att:fetch(att_len, Att), - couch_att:fetch(att_len, AttTarget)), - ?assertEqual(couch_att:fetch(type, Att), - couch_att:fetch(type, AttTarget)), - ?assertEqual(couch_att:fetch(md5, Att), - couch_att:fetch(md5, AttTarget)) + ?assertEqual( + couch_att:fetch(disk_len, Att), + couch_att:fetch(disk_len, AttTarget) + ), + ?assertEqual( + couch_att:fetch(att_len, Att), + couch_att:fetch(att_len, AttTarget) + ), + ?assertEqual( + couch_att:fetch(type, Att), + couch_att:fetch(type, AttTarget) + ), + ?assertEqual( + couch_att:fetch(md5, Att), + couch_att:fetch(md5, AttTarget) + ) end, lists:foreach(FunCompareAtts, Atts1). - find_att([], _Name) -> nil; find_att([Att | Rest], Name) -> @@ -89,38 +95,44 @@ find_att([Att | Rest], Name) -> find_att(Rest, Name) end. - att_md5(Att) -> Md50 = couch_att:foldl( Att, fun(Chunk, Acc) -> couch_hash:md5_hash_update(Acc, Chunk) end, - couch_hash:md5_hash_init()), + couch_hash:md5_hash_init() + ), couch_hash:md5_hash_final(Md50). att_decoded_md5(Att) -> Md50 = couch_att:foldl_decode( Att, fun(Chunk, Acc) -> couch_hash:md5_hash_update(Acc, Chunk) end, - couch_hash:md5_hash_init()), + couch_hash:md5_hash_init() + ), couch_hash:md5_hash_final(Md50). db_url(DbName) -> iolist_to_binary([ - "http://", config:get("httpd", "bind_address", "127.0.0.1"), - ":", integer_to_list(mochiweb_socket_server:get(couch_httpd, port)), - "/", DbName + "http://", + config:get("httpd", "bind_address", "127.0.0.1"), + ":", + integer_to_list(mochiweb_socket_server:get(couch_httpd, port)), + "/", + DbName ]). get_pid(RepId) -> - Pid = global:whereis_name({couch_replicator_scheduler_job,RepId}), + Pid = global:whereis_name({couch_replicator_scheduler_job, RepId}), ?assert(is_pid(Pid)), Pid. replicate(Source, Target) -> - replicate({[ - {<<"source">>, Source}, - {<<"target">>, Target} - ]}). + replicate( + {[ + {<<"source">>, Source}, + {<<"target">>, Target} + ]} + ). replicate({[_ | _]} = RepObject) -> {ok, Rep} = couch_replicator_utils:parse_rep_doc(RepObject, ?ADMIN_USER), |