Skip to content

Commit

Permalink
Fix {eaddrnotavail} in elixir tests under Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
big-r81 authored and janl committed Dec 21, 2022
1 parent 1c21426 commit 9aee170
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions test/elixir/lib/couch/dbtest.ex
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ defmodule Couch.DBTest do
userinfo
end

src = set_user(src, userinfo)
tgt = set_user(tgt, userinfo)
src = set_user(get_absolute_url(src), userinfo)
tgt = set_user(get_absolute_url(tgt), userinfo)

defaults = [headers: [], body: %{}, timeout: 30_000]
options = defaults |> Keyword.merge(options) |> Enum.into(%{})
Expand All @@ -320,6 +320,18 @@ defmodule Couch.DBTest do
resp.body
end

defp get_absolute_url("http://" <> _ = uri) do
uri
end

defp get_absolute_url("/" <> _ = uri) do
Couch.process_url(uri)
end

defp get_absolute_url(uri) do
Couch.process_url("/" <> uri)
end

defp set_user(uri, userinfo) do
case URI.parse(uri) do
%{scheme: nil} ->
Expand Down
2 changes: 1 addition & 1 deletion test/elixir/test/security_validation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ defmodule SecurityValidationTest do
foo2 = Map.put(foo2, "value", "b")
assert Couch.put("/#{db_name_b}/foo2", body: foo2, headers: spike).body["ok"]

result = replicate(db_name_b, db_name_a, headers: spike)
result = replicate(db_name_b, db_name_a, [{:userinfo, "spike:dog"}, {:headers, spike}])
assert Enum.at(result["history"], 0)["docs_written"] == 1
assert Enum.at(result["history"], 0)["doc_write_failures"] == 2

Expand Down

0 comments on commit 9aee170

Please sign in to comment.