Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 03643200C1D for ; Thu, 16 Feb 2017 18:58:47 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 01D36160B72; Thu, 16 Feb 2017 17:58:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4CF7F160B52 for ; Thu, 16 Feb 2017 18:58:46 +0100 (CET) Received: (qmail 88053 invoked by uid 500); 16 Feb 2017 17:58:45 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 88044 invoked by uid 99); 16 Feb 2017 17:58:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2017 17:58:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 69993DFC63; Thu, 16 Feb 2017 17:58:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davisp@apache.org To: commits@couchdb.apache.org Date: Thu, 16 Feb 2017 17:58:45 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] couch commit: updated refs/heads/COUCHDB-3288-remove-public-db-record to 9827918 [Forced Update!] archived-at: Thu, 16 Feb 2017 17:58:47 -0000 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 Authored: Wed Feb 1 15:15:09 2017 -0600 Committer: Paul J. Davis 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.