summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2019-01-30 10:16:37 +0200
committergarren smith <garren.smith@gmail.com>2019-01-30 11:07:12 +0200
commitf30fca21a5d5db136c694501526e4b2e01648977 (patch)
tree01fd330ac9b5fc6131e3d1eaa8f158bbf7fbeeb8
parent25838d078b1cf8ef5554f41c0b51d8628ca712ba (diff)
downloadcouchdb-f30fca21a5d5db136c694501526e4b2e01648977.tar.gz
Make it possible to override elixir couchdb settings via environmental variables
-rw-r--r--test/elixir/README.md11
-rw-r--r--test/elixir/lib/couch.ex7
2 files changed, 15 insertions, 3 deletions
diff --git a/test/elixir/README.md b/test/elixir/README.md
index 54de35929..20e01903b 100644
--- a/test/elixir/README.md
+++ b/test/elixir/README.md
@@ -11,7 +11,16 @@ mix deps.get
mix test --trace
```
-# Tests to port
+## Set CouchDB credentials
+
+By default the Elixir tests require CouchDB running at http://127.0.0.1:15984 with credentials `adm:pass`.
+You can override those using the following:
+
+```
+$ USER=myusername PASS=password COUCH_URL=http://my-couchdb.com mix test
+```
+
+## Tests to port
X means done, - means partially
diff --git a/test/elixir/lib/couch.ex b/test/elixir/lib/couch.ex
index 97a0f9b0e..a54ae7597 100644
--- a/test/elixir/lib/couch.ex
+++ b/test/elixir/lib/couch.ex
@@ -55,7 +55,8 @@ defmodule Couch do
end
def process_url(url) do
- "http://127.0.0.1:15984" <> url
+ baseUrl = System.get_env("COUCH_URL") || "http://127.0.0.1:15984"
+ baseUrl <> url
end
def process_request_headers(headers, options) do
@@ -84,7 +85,9 @@ defmodule Couch do
if headers[:basic_auth] != nil or headers[:authorization] != nil do
options
else
- Keyword.put(options, :basic_auth, {"adm", "pass"})
+ username = System.get_env("USER") || "adm"
+ password = System.get_env("PASS") || "pass"
+ Keyword.put(options, :basic_auth, {username, password})
end
else
options