Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ python-black-update: .venv/bin/black
.PHONY: elixir
elixir: export MIX_ENV=integration
elixir: elixir-init elixir-check-formatted elixir-credo devclean
@dev/run -a adm:pass --no-eval 'mix test --trace --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)'
@dev/run -a adm:pass -n 1 --no-eval 'mix test --trace --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)'

.PHONY: elixir-init
elixir-init: MIX_ENV=test
Expand Down
4 changes: 2 additions & 2 deletions src/dreyfus/test/elixir/test/partition_search_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule PartitionSearchTest do
end

resp = Couch.post("/#{db_name}/_bulk_docs", body: %{:docs => docs}, query: %{w: 3})
assert resp.status_code == 201
assert resp.status_code in [201, 202]
end

def create_ddoc(db_name, opts \\ %{}) do
Expand All @@ -39,7 +39,7 @@ defmodule PartitionSearchTest do
ddoc = Enum.into(opts, default_ddoc)

resp = Couch.put("/#{db_name}/_design/library", body: ddoc)
assert resp.status_code == 201
assert resp.status_code in [201, 202]
assert Map.has_key?(resp.body, "ok") == true
end

Expand Down
4 changes: 2 additions & 2 deletions test/elixir/lib/couch/db_test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ defmodule Couch.DBTest do
}
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]
end

def query(
Expand Down Expand Up @@ -251,7 +251,7 @@ defmodule Couch.DBTest do
body: ddoc
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]

resp = Couch.get("/#{db_name}/#{ddoc_name}/_view/view", query: request_options)
assert resp.status_code == 200
Expand Down
8 changes: 4 additions & 4 deletions test/elixir/test/all_docs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ defmodule AllDocsTest do
db_name = context[:db_name]

resp = Couch.post("/#{db_name}/_bulk_docs", body: %{docs: create_docs(0..2)})
assert resp.status_code == 201
assert resp.status_code in [201, 202]

resp = Couch.post(
"/#{db_name}/_all_docs",
Expand All @@ -240,7 +240,7 @@ defmodule AllDocsTest do
db_name = context[:db_name]

resp = Couch.post("/#{db_name}/_bulk_docs", body: %{docs: create_docs(0..3)})
assert resp.status_code == 201
assert resp.status_code in [201, 202]

resp = Couch.post(
"/#{db_name}/_all_docs",
Expand All @@ -259,7 +259,7 @@ defmodule AllDocsTest do
db_name = context[:db_name]

resp = Couch.post("/#{db_name}/_bulk_docs", body: %{docs: create_docs(0..3)})
assert resp.status_code == 201
assert resp.status_code in [201, 202]

resp = Couch.post(
"/#{db_name}/_all_docs",
Expand All @@ -280,7 +280,7 @@ defmodule AllDocsTest do
db_name = context[:db_name]

resp = Couch.post("/#{db_name}/_bulk_docs", body: %{docs: create_docs(0..3)})
assert resp.status_code == 201
assert resp.status_code in [201, 202]

resp = Couch.post(
"/#{db_name}/_all_docs",
Expand Down
2 changes: 1 addition & 1 deletion test/elixir/test/attachment_names_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ defmodule AttachmentNamesTest do
filename = URI.encode("Kолян.txt", &URI.char_unreserved?(&1))
resp = Couch.post("/#{db_name}", body: @good_doc)
msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

resp = Couch.get("/#{db_name}/good_doc/#{filename}")
assert resp.body == "This is a base64 encoded text"
Expand Down
8 changes: 4 additions & 4 deletions test/elixir/test/attachment_paths_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ defmodule AttachmentPathsTest do
resp = Couch.post("/#{db_name}", body: @bin_att_doc)
msg = "Should return 201-Created"

assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

rev = resp.body["rev"]

Expand Down Expand Up @@ -91,7 +91,7 @@ defmodule AttachmentPathsTest do
headers: ["Content-Type": "text/plain;charset=utf-8"]
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]

resp = Couch.get("/#{db_name}/bin_doc")
assert resp.status_code == 200
Expand Down Expand Up @@ -119,7 +119,7 @@ defmodule AttachmentPathsTest do

create_db(db_name)
resp = Couch.post("/#{db_name}", body: @design_att_doc)
assert resp.status_code == 201
assert resp.status_code in [201, 202]

rev = resp.body["rev"]

Expand Down Expand Up @@ -157,7 +157,7 @@ defmodule AttachmentPathsTest do
headers: ["Content-Type": "text/plain;charset=utf-8"]
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]

resp = Couch.get("/#{db_name}/_design/bin_doc")
assert resp.status_code == 200
Expand Down
8 changes: 4 additions & 4 deletions test/elixir/test/attachments_multipart_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defmodule AttachmentMultipartTest do
headers: ["Content-Type": "multipart/related;boundary=\"abc123\""]
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]
assert resp.body["ok"] == true

resp = Couch.get("/#{db_name}/multipart/foo.txt")
Expand Down Expand Up @@ -113,7 +113,7 @@ defmodule AttachmentMultipartTest do
headers: ["Content-Type": "multipart/related;boundary=\"abc123\""]
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]

resp = Couch.get("/#{db_name}/multipart/bar.txt")

Expand Down Expand Up @@ -278,7 +278,7 @@ defmodule AttachmentMultipartTest do
headers: ["Content-Type": "application/binary"]
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]
second_rev = resp.body["rev"]

resp =
Expand All @@ -289,7 +289,7 @@ defmodule AttachmentMultipartTest do
headers: ["Content-Type": "text/plain"]
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]
third_rev = resp.body["rev"]

resp =
Expand Down
8 changes: 4 additions & 4 deletions test/elixir/test/attachments_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ defmodule AttachmentsTest do
body: bin_data
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]

rev = resp.body["rev"]

Expand Down Expand Up @@ -213,7 +213,7 @@ defmodule AttachmentsTest do
body: "This is a string"
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]

resp = Couch.get("/#{db_name}/bin_doc4/attachment.txt")
assert resp.status_code == 200
Expand Down Expand Up @@ -315,7 +315,7 @@ defmodule AttachmentsTest do
headers: ["Content-Type": "text/plain;charset=utf-8"]
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]
rev = resp.body["rev"]

resp =
Expand All @@ -326,7 +326,7 @@ defmodule AttachmentsTest do
headers: ["Content-Type": "text/plain;charset=utf-8"]
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]
end

@tag :with_db
Expand Down
2 changes: 1 addition & 1 deletion test/elixir/test/basics_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ defmodule BasicsTest do
@tag :with_db
test "Create a document and save it to the database", context do
resp = Couch.post("/#{context[:db_name]}", body: %{:_id => "0", :a => 1, :b => 1})
assert resp.status_code == 201, "Should be 201 created"
assert resp.status_code in [201, 202], "Should be 201 created"
assert resp.body["id"], "Id should be present"
assert resp.body["rev"], "Rev should be present"

Expand Down
4 changes: 2 additions & 2 deletions test/elixir/test/bulk_docs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule BulkDocsTest do
# Update just the first doc to create a conflict in subsequent bulk update
doc = hd(docs)
resp = Couch.put("/#{db}/#{doc._id}", body: doc)
assert resp.status_code == 201
assert resp.status_code in [201, 202]
# Attempt to delete all docs
docs = Enum.map(docs, fn doc -> Map.put(doc, :_deleted, true) end)

Expand Down Expand Up @@ -133,7 +133,7 @@ defmodule BulkDocsTest do
retry_until(fn ->
resp = Couch.post("/#{db}/_bulk_docs", body: %{docs: docs})

assert resp.status_code == 201 and length(resp.body) == length(docs), """
assert resp.status_code in [201, 202] and length(resp.body) == length(docs), """
Expected 201 and the same number of response rows as in request, but got
#{pretty_inspect(resp)}
"""
Expand Down
12 changes: 6 additions & 6 deletions test/elixir/test/cluster_with_quorum_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule WithQuorumTest do
db_name = context[:db_name]
resp = Couch.put("/#{db_name}")
msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg
resp = Couch.delete("/#{db_name}")
msg = "Should return 202-Acepted"
assert resp.status_code == 202, msg
Expand All @@ -24,7 +24,7 @@ defmodule WithQuorumTest do

resp = Couch.post("/#{context[:db_name]}", body: %{:_id => "0", :a => 1})
msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

resp = Couch.get("/#{context[:db_name]}/0")
rev = resp.body["_rev"]
Expand All @@ -33,7 +33,7 @@ defmodule WithQuorumTest do
Couch.put("/#{context[:db_name]}/0", body: %{:_id => "0", :_rev => rev, :a => 2})

msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

resp = Couch.get("/#{context[:db_name]}/0")
rev = resp.body["_rev"]
Expand Down Expand Up @@ -95,7 +95,7 @@ defmodule WithQuorumTest do
headers = [Destination: "1"]
resp = Couch.request(:copy, "/#{context[:db_name]}/0", headers: headers)
msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg
Couch.delete("/#{db_name}")
end

Expand All @@ -108,7 +108,7 @@ defmodule WithQuorumTest do
docs = create_docs(@doc_range)
resp = Couch.post("/#{db_name}/_bulk_docs", body: %{docs: docs})
msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

Couch.delete("/#{db_name}")
end
Expand Down Expand Up @@ -141,7 +141,7 @@ defmodule WithQuorumTest do
)

msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

rev = resp.body["rev"]
resp = Couch.delete("/#{context[:db_name]}/0/foo.txt", query: %{:rev => rev})
Expand Down
8 changes: 4 additions & 4 deletions test/elixir/test/cluster_without_quorum_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ defmodule WithoutQuorumTest do
)

msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

resp = Couch.get("/#{context[:db_name]}/0")
rev = resp.body["_rev"]
Expand All @@ -70,7 +70,7 @@ defmodule WithoutQuorumTest do
)

msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

resp = Couch.get("/#{context[:db_name]}/0")
rev = resp.body["_rev"]
Expand Down Expand Up @@ -119,7 +119,7 @@ defmodule WithoutQuorumTest do
docs = create_docs(@doc_range)
resp = Couch.post("/#{db_name}/_bulk_docs", query: %{:w => 1}, body: %{docs: docs})
msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

Couch.delete("/#{db_name}")
end
Expand Down Expand Up @@ -166,7 +166,7 @@ defmodule WithoutQuorumTest do
)

msg = "Should return 201-Created"
assert resp.status_code == 201, msg
assert resp.status_code in [201, 202], msg

rev = resp.body["rev"]

Expand Down
6 changes: 3 additions & 3 deletions test/elixir/test/compact_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ defmodule CompactTest do
defp populate(db) do
docs = create_docs(0..19)
resp = Couch.post("/#{db}/_bulk_docs", body: %{docs: docs})
assert resp.status_code == 201
assert resp.status_code in [201, 202]
docs = rev(docs, resp.body)

doc = %{
Expand All @@ -71,14 +71,14 @@ defmodule CompactTest do
}

resp = Couch.put("/#{db}/#{doc._id}", body: doc)
assert resp.status_code == 201
assert resp.status_code in [201, 202]
docs
end

defp delete(db, docs) do
docs = Enum.map(docs, &Map.put(&1, :_deleted, true))
resp = Couch.post("/#{db}/_bulk_docs", body: %{docs: docs})
assert resp.status_code == 201
assert resp.status_code in [201, 202]
assert Couch.post("/#{db}/_ensure_full_commit").body["ok"] == true
end

Expand Down
4 changes: 2 additions & 2 deletions test/elixir/test/copy_doc_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule CopyDocTest do
)

assert resp.body["ok"]
assert resp.status_code == 201
assert resp.status_code in [201, 202]

assert Couch.get("/#{db_name}/doc_that_was_copied").body["v"] == 1

Expand Down Expand Up @@ -63,7 +63,7 @@ defmodule CopyDocTest do
headers: [Destination: "doc_to_be_overwritten?rev=#{rev}"]
)

assert resp.status_code == 201
assert resp.status_code in [201, 202]
resp = Couch.get("/#{db_name}/doc_to_be_overwritten")
assert resp.body["_rev"] != rev
assert resp.body["v"] == 1
Expand Down
2 changes: 1 addition & 1 deletion test/elixir/test/lots_of_docs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ defmodule LotsOfDocsTest do
defp bulk_post(docs, db) do
resp = Couch.post("/#{db}/_bulk_docs", query: [w: 3], body: %{docs: docs})

assert resp.status_code == 201 and length(resp.body) == length(docs), """
assert resp.status_code in [201, 202] and length(resp.body) == length(docs), """
Expected 201 and the same number of response rows as in request, but got
#{pretty_inspect(resp)}
"""
Expand Down
Loading