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 9B03E200C46 for ; Tue, 21 Feb 2017 18:45:52 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 99BE2160B7A; Tue, 21 Feb 2017 17:45:52 +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 E18DA160B74 for ; Tue, 21 Feb 2017 18:45:51 +0100 (CET) Received: (qmail 23956 invoked by uid 500); 21 Feb 2017 17:45:51 -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 23780 invoked by uid 99); 21 Feb 2017 17:45:51 -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; Tue, 21 Feb 2017 17:45:51 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9F92CE0082; Tue, 21 Feb 2017 17:45:50 +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: Tue, 21 Feb 2017 17:46:00 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [11/13] couch commit: updated refs/heads/COUCHDB-3288-remove-public-db-record to b424a88 archived-at: Tue, 21 Feb 2017 17:45:52 -0000 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/4aa973d4 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/4aa973d4 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/4aa973d4 Branch: refs/heads/COUCHDB-3288-remove-public-db-record Commit: 4aa973d4385ffdf919ae7bdc7e9306f5112eb628 Parents: 0ac807a Author: Paul J. Davis Authored: Wed Feb 1 15:15:09 2017 -0600 Committer: Paul J. Davis Committed: Tue Feb 21 11:44:36 2017 -0600 ---------------------------------------------------------------------- src/test_util.erl | 12 ++++++++++++ 1 file changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/4aa973d4/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.