You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2018/06/22 22:15:56 UTC
[couchdb] 27/31: Allow tests to set config values dynamically
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 <pa...@gmail.com>
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