Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ elixir: elixir-init devclean
--erlang-config rel/files/eunit.config \
--no-eval 'mix test --trace --include test/elixir/test/config/suite.elixir --exclude test/elixir/test/config/skip.elixir $(EXUNIT_OPTS)'

elixir-pouchdb: export MIX_ENV=integration
elixir-pouchdb: elixir-init devclean
@mix test --trace test/elixir/test/* --exclude skip_for_pouchdb_server :true --max-failures 1 --seed 0 $(EXUNIT_OPTS)

ifneq ($(CLOUSEAU_DIR),)
_WITH_CLOUSEAU="--with-clouseau --clouseau-dir=$(CLOUSEAU_DIR)"
else ifeq ($(with_clouseau), true)
Expand Down
7 changes: 5 additions & 2 deletions test/elixir/lib/couch/dbtest.ex
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,12 @@ defmodule Couch.DBTest do
{:ok, resp}
end

def reset_db(db_name, opts \\ []) do
def reset_db(db_name, _opts \\ []) do
delete_db(db_name)
create_db(db_name, opts)
retry_until(fn ->
resp = Couch.get("/#{db_name}")
assert resp.status_code == 200
end)
end

# Use this function when testing authentication after resetting (re-creating)
Expand Down
4 changes: 4 additions & 0 deletions test/elixir/test/all_docs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule AllDocsTest do
# var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"}, {w: 3});

@tag :with_db
@tag skip_for_pouchdb_server: true
test "All Docs tests", context do
db_name = context[:db_name]
resp1 = Couch.post("/#{db_name}", body: %{:_id => "0", :a => 1, :b => 1}).body
Expand Down Expand Up @@ -220,6 +221,7 @@ defmodule AllDocsTest do


@tag :with_db
@tag skip_for_pouchdb_server: true
test "POST with empty body", context do
db_name = context[:db_name]

Expand All @@ -236,6 +238,7 @@ defmodule AllDocsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "POST with keys and limit", context do
db_name = context[:db_name]

Expand Down Expand Up @@ -276,6 +279,7 @@ defmodule AllDocsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "POST edge case with colliding parameters - query takes precedence", context do
db_name = context[:db_name]

Expand Down
1 change: 1 addition & 0 deletions test/elixir/test/attachment_names_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ defmodule AttachmentNamesTest do
This is a port of the attachment_names.js suite
"""

@tag skip_for_pouchdb_server: true
@tag :with_db
test "saves attachment names successfully", context do
db_name = context[:db_name]
Expand Down
1 change: 1 addition & 0 deletions test/elixir/test/attachment_paths_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ defmodule AttachmentPathsTest do
"""

@tag :with_db_name
@tag skip_for_pouchdb_server: true
test "manages attachment paths successfully", context do
db_name =
URI.encode(
Expand Down
1 change: 1 addition & 0 deletions test/elixir/test/attachment_ranges_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule AttachmentRangesTest do
This is a port of the attachment_ranges.js suite
"""

@tag skip_for_pouchdb_server: true
@tag :with_db
test "manages attachment range requests successfully", context do
db_name = context[:db_name]
Expand Down
1 change: 1 addition & 0 deletions test/elixir/test/attachment_views_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule AttachmentViewTest do
This is a port of the attachment_views.js suite
"""

@tag skip_for_pouchdb_server: true
@tag :with_db
test "manages attachments in views successfully", context do
db_name = context[:db_name]
Expand Down
3 changes: 3 additions & 0 deletions test/elixir/test/attachments_multipart_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defmodule AttachmentMultipartTest do
"""

@tag :with_db
@tag skip_for_pouchdb_server: true
test "manages attachments multipart requests successfully", context do
db_name = context[:db_name]

Expand Down Expand Up @@ -235,6 +236,7 @@ defmodule AttachmentMultipartTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "manages compressed attachments successfully", context do
db_name = context[:db_name]

Expand All @@ -260,6 +262,7 @@ defmodule AttachmentMultipartTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "multipart attachments with new_edits=false", context do
db_name = context[:db_name]

Expand Down
5 changes: 5 additions & 0 deletions test/elixir/test/attachments_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ defmodule AttachmentsTest do
assert resp.body["ok"]
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "errors for bad attachment", context do
db_name = context[:db_name]
Expand Down Expand Up @@ -97,6 +98,7 @@ defmodule AttachmentsTest do
assert Regex.match?(~r/bin_doc2\/foo2.txt/, resp.headers["location"])
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "delete attachment", context do
db_name = context[:db_name]
Expand Down Expand Up @@ -124,6 +126,7 @@ defmodule AttachmentsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "delete attachment request with a payload should not block following requests", context do
db_name = context[:db_name]

Expand Down Expand Up @@ -370,6 +373,7 @@ defmodule AttachmentsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "COUCHDB-809 - stubs should only require the 'stub' field", context do
db_name = context[:db_name]

Expand Down Expand Up @@ -431,6 +435,7 @@ defmodule AttachmentsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "attachment via multipart/form-data", context do
db_name = context[:db_name]

Expand Down
1 change: 1 addition & 0 deletions test/elixir/test/auth_lockout_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defmodule AuthLockoutTest do
}
]

@tag skip_for_pouchdb_server: true
test "lockout after multiple failed authentications", _context do
server_config = [
%{
Expand Down
14 changes: 14 additions & 0 deletions test/elixir/test/basics_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defmodule BasicsTest do
assert user_ctx["roles"] == ["_admin"], "Should have _admin role"
end

@tag skip_for_pouchdb_server: true
test "Welcome endpoint" do
assert Couch.get("/").body["couchdb"] == "Welcome", "Should say welcome"
end
Expand All @@ -35,6 +36,7 @@ defmodule BasicsTest do
{:ok, _} = delete_db(db_name)
end

@tag skip_for_pouchdb_server: true
@tag :with_db_name
test "Creating a new DB with slashes should return Location header (COUCHDB-411)",
context do
Expand All @@ -59,6 +61,7 @@ defmodule BasicsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "Limit and skip should work in _all_dbs", context do
db = context[:db_name]
db_count = length(Couch.get("/_all_dbs").body)
Expand All @@ -69,6 +72,7 @@ defmodule BasicsTest do
assert [db] == Couch.get("/_all_dbs?start_key=\"#{db}\"&limit=1").body
end

@tag skip_for_pouchdb_server: true
test "Database name with '+' should encode to '+'", _context do
set_config({"chttpd", "decode_plus_to_space", "false"})

Expand All @@ -85,6 +89,7 @@ defmodule BasicsTest do
assert resp.body["db_name"] == db_name
end

@tag skip_for_pouchdb_server: true
test "Database name with '%2B' should encode to '+'", _context do
set_config({"chttpd", "decode_plus_to_space", "true"})

Expand Down Expand Up @@ -114,6 +119,7 @@ defmodule BasicsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "'+' in document name should encode to space", context do
set_config({"chttpd", "decode_plus_to_space", "true"})

Expand Down Expand Up @@ -144,6 +150,7 @@ defmodule BasicsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "Revs info status is good", context do
db_name = context[:db_name]
{:ok, _} = create_doc(db_name, sample_doc_foo())
Expand All @@ -152,6 +159,7 @@ defmodule BasicsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "A document read with etag works", context do
db_name = context[:db_name]
{:ok, resp} = create_doc(db_name, sample_doc_foo())
Expand All @@ -162,6 +170,7 @@ defmodule BasicsTest do
assert resp.body == "", "Should have an empty body"
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "Make sure you can do a seq=true option", context do
db_name = context[:db_name]
Expand Down Expand Up @@ -300,6 +309,7 @@ defmodule BasicsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "Check for invalid document members", context do
db_name = context[:db_name]

Expand Down Expand Up @@ -340,6 +350,7 @@ defmodule BasicsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "_all_docs POST error when multi-get is not a {'key': [...]} structure", context do
db_name = context[:db_name]
resp = Couch.post("/#{db_name}/_all_docs", body: "[]")
Expand All @@ -353,6 +364,7 @@ defmodule BasicsTest do
assert resp.body["reason"] == "`keys` body member must be an array."
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "oops, the doc id got lost in code nirwana", context do
db_name = context[:db_name]
Expand All @@ -373,6 +385,7 @@ defmodule BasicsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "Default headers are returned for doc with open_revs=all", context do
db_name = context[:db_name]
post_response = Couch.post("/#{db_name}", body: %{:foo => :bar})
Expand All @@ -382,6 +395,7 @@ defmodule BasicsTest do
assert head_response.headers["X-CouchDB-Body-Time"]
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "request ID can be specified at the client", _context do
uuid = "E7498DE1-B661-42FA-943D-17F890143068"
Expand Down
3 changes: 3 additions & 0 deletions test/elixir/test/batch_save_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ defmodule BatchSaveTest do

@doc_count 100

@tag skip_for_pouchdb_server: true
@tag :with_db
test "batch put", context do
path_fun = &"/#{&1}/#{&2}"
run(&Couch.put/2, path_fun, context[:db_name], @doc_count)
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "batch post", context do
path_fun = fn db_name, _ -> "/#{db_name}" end
run(&Couch.post/2, path_fun, context[:db_name], @doc_count)
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "batch put with identical doc ids", context do
path_fun = fn db_name, _ -> "/#{db_name}/foo" end
Expand Down
5 changes: 5 additions & 0 deletions test/elixir/test/bulk_docs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defmodule BulkDocsTest do

@doc_range 1..5

@tag skip_for_pouchdb_server: true
@tag :with_db
test "bulk docs can create, update, & delete many docs per request", ctx do
db = ctx[:db_name]
Expand Down Expand Up @@ -77,6 +78,7 @@ defmodule BulkDocsTest do
assert res["rev"]
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "bulk docs raises error for `all_or_nothing` option", ctx do
opts = [body: %{docs: create_docs(@doc_range), all_or_nothing: true}]
Expand All @@ -100,6 +102,7 @@ defmodule BulkDocsTest do
assert Enum.count(body, &Map.get(&1, "rev")) == 1
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "bulk docs raises error for missing `docs` parameter", ctx do
docs = [%{foo: "bar"}]
Expand All @@ -108,11 +111,13 @@ defmodule BulkDocsTest do
end

@tag :with_db
@tag skip_for_pouchdb_server: true
test "bulk docs raises error for invalid `docs` parameter", ctx do
resp = Couch.post("/#{ctx[:db_name]}/_bulk_docs", body: %{docs: "foo"})
assert_bad_request(resp, "`docs` parameter must be an array.")
end

@tag skip_for_pouchdb_server: true
@tag :with_db
test "bulk docs raises error for invalid `new_edits` parameter", ctx do
opts = [body: %{docs: [], new_edits: 0}]
Expand Down
Loading