You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/02/28 11:03:59 UTC
[GitHub] [couchdb] iilyak edited a comment on issue #2602: Prototype/fdb
layer rebase
iilyak edited a comment on issue #2602: Prototype/fdb layer rebase
URL: https://github.com/apache/couchdb/pull/2602#issuecomment-592464389
I propose following change:
```
diff --git a/src/chttpd/test/exunit/tracing_test.exs b/src/chttpd/test/exunit/tracing_test.exs
index b50ef936e..f66fb87a2 100644
--- a/src/chttpd/test/exunit/tracing_test.exs
+++ b/src/chttpd/test/exunit/tracing_test.exs
@@ -29,7 +29,7 @@ defmodule Couch.Test.OpenTracing do
setup context do
db_name = Utils.random_name("db")
- session = Couch.login(context.base_url, context.user, context.pass)
+ session = Couch.login(context.user, context.pass, base_url: context.base_url)
on_exit(fn ->
delete_db(session, db_name)
diff --git a/test/elixir/lib/couch.ex b/test/elixir/lib/couch.ex
index cf105c743..9b577e002 100644
--- a/test/elixir/lib/couch.ex
+++ b/test/elixir/lib/couch.ex
@@ -3,7 +3,6 @@ defmodule Couch.Session do
CouchDB session helpers.
"""
- @enforce_keys [:cookie]
defstruct [:cookie, :error, :base_url]
def new(cookie, error \\ "") do
@@ -165,26 +164,25 @@ defmodule Couch do
login(user, pass)
end
- def login(user, pass, expect \\ :success) do
- base_url = System.get_env("EX_COUCH_URL") || "http://127.0.0.1:15984"
- login(base_url, user, pass, expect)
- end
-
- def login(base_url, user, pass, expect \\ :success) do
+ def login(user, pass, options \\ []) do
+ options = options |> Enum.into(%{})
+ base_url = Map.get_lazy(options, :base_url, fn ->
+ System.get_env("EX_COUCH_URL") || "http://127.0.0.1:15984"
+ end)
resp = Couch.post(
"/_session",
body: %{:username => user, :password => pass},
base_url: base_url
)
-
- if expect == :success do
+ if Map.get(options, :expect, :success) == :success do
true = resp.body["ok"]
cookie = resp.headers[:"set-cookie"]
[token | _] = String.split(cookie, ";")
- %Couch.Session{cookie: token}
+ %Couch.Session{cookie: token, base_url: base_url}
else
true = Map.has_key?(resp.body, "error")
- %Couch.Session{error: resp.body["error"]}
+ %Couch.Session{error: resp.body["error"], base_url: base_url}
end
end
+
end
diff --git a/test/elixir/test/auth_cache_test.exs b/test/elixir/test/auth_cache_test.exs
index 2ba396de7..5582b2f96 100644
--- a/test/elixir/test/auth_cache_test.exs
+++ b/test/elixir/test/auth_cache_test.exs
@@ -56,7 +56,7 @@ defmodule AuthCacheTest do
end
defp login_fail(user, password) do
- resp = Couch.login(user, password, :fail)
+ resp = Couch.login(user, password, expect: :fail)
assert resp.error, "Login error is expected."
end
```
Unfortunately I cannot test it. My attempts fail with:
```
==> chttpd (compile)
src/couchdb/src/chttpd/src/chttpd_changes.erl:88: field seq_btree undefined in record mrview
Compiling src/couchdb/src/chttpd/src/chttpd_changes.erl failed:
ERROR: compile failed while processing src/couchdb/src/chttpd: rebar_abort
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services