This is an automated email from the ASF dual-hosted git repository. davisp pushed a commit to branch COUCHDB-3288-mixed-cluster-upgrade in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 244602f5f4205f4460ba3c02fde974f19a82e91d Author: Paul J. Davis <[email protected]> AuthorDate: Wed Feb 1 15:15:09 2017 -0600 Add a test helper for creating fake db records COUCHDB-3288 --- src/couch/src/test_util.erl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/couch/src/test_util.erl b/src/couch/src/test_util.erl index e652dd9..8a05e88 100644 --- a/src/couch/src/test_util.erl +++ b/src/couch/src/test_util.erl @@ -13,6 +13,8 @@ -module(test_util). -include_lib("couch/include/couch_eunit.hrl"). +-include("couch_db.hrl"). +-include("couch_db_int.hrl"). -export([init_code_path/0]). -export([source_file/1, build_file/1]). @@ -32,6 +34,8 @@ -export([start/1, start/2, start/3, stop/1]). +-export([fake_db/1]). + -record(test_context, {mocked = [], started = [], module}). -define(DEFAULT_APPS, @@ -230,6 +234,16 @@ stop(#test_context{mocked = Mocked, started = Apps}) -> meck:unload(Mocked), stop_applications(Apps). +fake_db(Fields) -> + Indexes = lists:zip( + record_info(fields, db), + lists:seq(2, record_info(size, db)) + ), + lists:foldl(fun({FieldName, Value}, Acc) -> + Idx = couch_util:get_value(FieldName, Indexes), + setelement(Idx, Acc, Value) + end, #db{}, Fields). + now_us() -> {MegaSecs, Secs, MicroSecs} = now(), (MegaSecs * 1000000 + Secs) * 1000000 + MicroSecs. -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
