couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [26/36] couch commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to 0fbcd0c
Date Thu, 06 Apr 2017 16:16:40 GMT
Add a test helper for creating fake db records

COUCHDB-3288


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/552a29d1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/552a29d1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/552a29d1

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: 552a29d1e107014dab6c209f2f91a5c33af89728
Parents: 73c273f
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed Feb 1 15:15:09 2017 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Tue Apr 4 16:32:27 2017 -0500

----------------------------------------------------------------------
 src/test_util.erl | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/552a29d1/src/test_util.erl
----------------------------------------------------------------------
diff --git a/src/test_util.erl b/src/test_util.erl
index 3c4d170..b5bb232 100644
--- a/src/test_util.erl
+++ b/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]).
@@ -229,6 +231,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.


Mime
View raw message