couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [1/2] couch commit: updated refs/heads/COUCHDB-3288-remove-public-db-record to 9827918 [Forced Update!]
Date Thu, 16 Feb 2017 17:58:45 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/COUCHDB-3288-remove-public-db-record c9fc36129 -> 98279181a (forced update)


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/62361294
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/62361294
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/62361294

Branch: refs/heads/COUCHDB-3288-remove-public-db-record
Commit: 623612946029a7ed6c059e3c45de584395dd94a0
Parents: e4b4b57
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: Thu Feb 16 11:56:07 2017 -0600

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


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/62361294/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