From commits-return-33434-archive-asf-public=cust-asf.ponee.io@couchdb.apache.org Sat Jun 23 00:15:41 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id AE309180647 for ; Sat, 23 Jun 2018 00:15:40 +0200 (CEST) Received: (qmail 25655 invoked by uid 500); 22 Jun 2018 22:15:33 -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 25439 invoked by uid 99); 22 Jun 2018 22:15:32 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jun 2018 22:15:32 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 1639C85155; Fri, 22 Jun 2018 22:15:31 +0000 (UTC) Date: Fri, 22 Jun 2018 22:15:56 +0000 To: "commits@couchdb.apache.org" Subject: [couchdb] 27/31: Allow tests to set config values dynamically MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: chewbranca@apache.org In-Reply-To: <152970572990.14313.14230390126740126062@gitbox.apache.org> References: <152970572990.14313.14230390126740126062@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: couchdb X-Git-Refname: refs/heads/elixir-suite X-Git-Reftype: branch X-Git-Rev: 534739fe56422245b3f48e9f686f70168efe3b11 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20180622221531.1639C85155@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. chewbranca pushed a commit to branch elixir-suite in repository https://gitbox.apache.org/repos/asf/couchdb.git commit 534739fe56422245b3f48e9f686f70168efe3b11 Author: Paul J. Davis AuthorDate: Fri Jan 26 14:31:47 2018 -0600 Allow tests to set config values dynamically --- test/elixir/test/test_helper.exs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/elixir/test/test_helper.exs b/test/elixir/test/test_helper.exs index cb01fc2..9baf204 100644 --- a/test/elixir/test/test_helper.exs +++ b/test/elixir/test/test_helper.exs @@ -66,15 +66,7 @@ defmodule CouchTestCase do end def set_config({section, key, value}) do - resp = Couch.get("/_membership") - existing = Enum.map(resp.body["all_nodes"], fn node -> - url = "/_node/#{node}/_config/#{section}/#{key}" - headers = ["X-Couch-Persist": "false"] - body = :jiffy.encode(value) - resp = Couch.put(url, headers: headers, body: body) - assert resp.status_code == 200 - {node, resp.body} - end) + existing = set_config_raw(section, key, value) on_exit(fn -> Enum.each(existing, fn {node, prev_value} -> if prev_value != "" do @@ -93,6 +85,18 @@ defmodule CouchTestCase do end) end + def set_config_raw(section, key, value) do + resp = Couch.get("/_membership") + Enum.map(resp.body["all_nodes"], fn node -> + url = "/_node/#{node}/_config/#{section}/#{key}" + headers = ["X-Couch-Persist": "false"] + body = :jiffy.encode(value) + resp = Couch.put(url, headers: headers, body: body) + assert resp.status_code == 200 + {node, resp.body} + end) + end + def create_db(db_name) do resp = Couch.put("/#{db_name}") assert resp.status_code == 201