You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2023/05/21 16:28:11 UTC

[couchdb] 01/02: mango: fix the faulty `index_array_length` tests

This is an automated email from the ASF dual-hosted git repository.

jaydoane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 751c14dc3294433dc846f324822771a0d6f8630f
Author: Gabor Pali <ga...@ibm.com>
AuthorDate: Sun May 21 02:30:20 2023 +0200

    mango: fix the faulty `index_array_length` tests
    
    - They do not check the count of the returned documents but blindly
      assume that there will be results.  Add an explicit assertion about
      the expected number of documents in the response so it could be
      detected if something breaks.
    
    - The assertion on the document count revealed that the test database
      is actually empty because it is immediately wiped out after creation
      by a misplaced `recreate()` call.
    
    - When the indexing on the array lengths is disabled, there shall be no
      documents returned, and not the sizes of the `favorites` arrays in
      the results shall be zero.  That is because there is no information
      available on the sizes of the arrays.
---
 src/mango/test/10-disable-array-length-field-test.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/mango/test/10-disable-array-length-field-test.py b/src/mango/test/10-disable-array-length-field-test.py
index ea3279b55..297ebeace 100644
--- a/src/mango/test/10-disable-array-length-field-test.py
+++ b/src/mango/test/10-disable-array-length-field-test.py
@@ -17,7 +17,6 @@ import unittest
 @unittest.skipUnless(mango.has_text_service(), "requires text service")
 class DisableIndexArrayLengthsTest(mango.UserDocsTextTests):
     def setUp(self):
-        self.db.recreate()
         self.db.create_text_index(
             ddoc="disable_index_array_lengths",
             analyzer="keyword",
@@ -33,12 +32,12 @@ class DisableIndexArrayLengthsTest(mango.UserDocsTextTests):
         docs = self.db.find(
             {"favorites": {"$size": 4}}, use_index="disable_index_array_lengths"
         )
-        for d in docs:
-            assert len(d["favorites"]) == 0
+        assert len(docs) == 0
 
     def test_enable_index_array_length(self):
         docs = self.db.find(
             {"favorites": {"$size": 4}}, use_index="explicit_enable_index_array_lengths"
         )
+        assert len(docs) > 0
         for d in docs:
             assert len(d["favorites"]) == 4