Skip to content

Commit 6c3a5a1

Browse files
committed
test: port 19-find-conflicts from python to elixir
1 parent fe3fc9f commit 6c3a5a1

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

test/elixir/test/config/suite.elixir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,5 +735,8 @@
735735
],
736736
"IgnoreDesignDocsForAllDocsIndexTests": [
737737
"should not return design docs"
738+
],
739+
"ChooseCorrectIndexForDocs": [
740+
"retrieve conflicts"
738741
]
739742
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
2+
# use this file except in compliance with the License. You may obtain a copy of
3+
# the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations under
11+
# the License.
12+
13+
defmodule ChooseCorrectIndexForDocs do
14+
use CouchTestCase
15+
16+
@db_name "find-conflicts"
17+
18+
setup do
19+
doc = %{"_id" => "doc", "a" => 2}
20+
conflicts = [%{"_id" => "doc", "_rev" => "1-23202479633c2b380f79507a776743d5", "a" => 1}]
21+
22+
MangoDatabase.recreate(@db_name)
23+
MangoDatabase.save_doc(@db_name, doc)
24+
MangoDatabase.save_docs_with_conflicts(@db_name, conflicts)
25+
:ok
26+
end
27+
28+
test "retrieve conflicts" do
29+
MangoDatabase.create_index(@db_name, ["_conflicts"])
30+
selector = %{"_conflicts" => %{"$exists" => true}}
31+
{:ok, result} = MangoDatabase.find(@db_name, selector, conflicts: true)
32+
33+
assert Enum.at(result, 0)["_conflicts"] == ["1-23202479633c2b380f79507a776743d5"]
34+
assert Enum.at(result, 0)["_rev"] == "1-3975759ccff3842adf690a5c10caee42"
35+
end
36+
end

0 commit comments

Comments
 (0)