diff --git a/src/mango/test/13-stable-update-test.py b/src/mango/test/13-stable-update-test.py deleted file mode 100644 index aebe622710b..00000000000 --- a/src/mango/test/13-stable-update-test.py +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -import copy -import mango - -DOCS1 = [ - { - "_id": "54af50626de419f5109c962f", - "user_id": 0, - "age": 10, - "name": "Jimi", - "location": "UK", - "number": 4, - }, - { - "_id": "54af50622071121b25402dc3", - "user_id": 1, - "age": 12, - "name": "Eddie", - "location": "ZAR", - "number": 2, - }, -] - - -class SupportStableAndUpdate(mango.DbPerClass): - def setUp(self): - super().setUp(db_per_test=True) - # Hack to prevent auto-indexer from foiling update=False test - # https://github.com/apache/couchdb/issues/2313 - self.db.save_doc( - {"_id": "_design/foo", "language": "query", "autoupdate": False} - ) - self.db.create_index(["name"], ddoc="foo") - self.db.save_docs(copy.deepcopy(DOCS1)) - - def test_update_updates_view_when_specified(self): - docs = self.db.find({"name": "Eddie"}, update=False) - assert len(docs) == 0 - docs = self.db.find({"name": "Eddie"}, update=True) - assert len(docs) == 1 diff --git a/test/elixir/test/config/suite.elixir b/test/elixir/test/config/suite.elixir index b3fb950846c..8bf012a42aa 100644 --- a/test/elixir/test/config/suite.elixir +++ b/test/elixir/test/config/suite.elixir @@ -735,5 +735,8 @@ ], "IgnoreDesignDocsForAllDocsIndexTests": [ "should not return design docs" + ], + "SupportStableAndUpdate": [ + "update updates view when specified" ] } diff --git a/test/elixir/test/mango/13_stable_update_test.exs b/test/elixir/test/mango/13_stable_update_test.exs new file mode 100644 index 00000000000..3378237098e --- /dev/null +++ b/test/elixir/test/mango/13_stable_update_test.exs @@ -0,0 +1,52 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +defmodule SupportStableAndUpdate do + use CouchTestCase + + @db_name "supports-stable-and-update" + @docs1 [ + %{ + "_id" => "54af50626de419f5109c962f", + "user_id" => 0, + "age" => 10, + "name" => "Jimi", + "location" => "UK", + "number" => 4, + }, + %{ + "_id" => "54af50622071121b25402dc3", + "user_id" => 1, + "age" => 12, + "name" => "Eddie", + "location" => "ZAR", + "number" => 2, + }, + ] + + setup do + MangoDatabase.recreate(@db_name) + # Hack to prevent auto-indexer from foiling update=False test + # https://github.com/apache/couchdb/issues/2313 + MangoDatabase.save_doc(@db_name, %{"_id" => "_design/foo", "language" => "query", "autoupdate" => false}) + MangoDatabase.create_index(@db_name, ["name"], ddoc: "foo") + MangoDatabase.save_docs(@db_name, @docs1) + :ok + end + + test "update updates view when specified" do + {:ok, docs} = MangoDatabase.find(@db_name, %{"name" => "Eddie"}, update: false) + assert Enum.empty?(docs) + {:ok, docs} = MangoDatabase.find(@db_name, %{"name" => "Eddie"}, update: true) + assert length(docs) == 1 + end +end diff --git a/test/elixir/test/support/mango_database.ex b/test/elixir/test/support/mango_database.ex index 1b5b4ab63a8..06a4114645e 100644 --- a/test/elixir/test/support/mango_database.ex +++ b/test/elixir/test/support/mango_database.ex @@ -187,6 +187,7 @@ defmodule MangoDatabase do |> put_if_set("fields", options, :fields) |> put_if_set("execution_stats", options, :executionStats) |> put_if_set("allow_fallback", options, :allow_fallback) + |> put_if_set("update", options, :update) ) case {(options[:explain] or options[:return_raw]), resp.status_code} do