Browse Source

Fix test bug: test expects at least one child document.

Adrien Grand 11 years ago
parent
commit
62b044697a

+ 4 - 0
src/test/java/org/elasticsearch/index/search/child/ParentConstantScoreQueryTests.java

@@ -101,6 +101,10 @@ public class ParentConstantScoreQueryTests extends ElasticsearchLuceneTestCase {
             } else {
                 numChildDocs = random().nextInt(TEST_NIGHTLY ? 40 : 10);
             }
+            if (parentDocId == numParentDocs - 1 && childIdToParentId.isEmpty()) {
+                // ensure there is at least one child in the index
+                numChildDocs = Math.max(1, numChildDocs);
+            }
             for (int i = 0; i < numChildDocs; i++) {
                 boolean markChildAsDeleted = rarely();
                 boolean filterMe = rarely();

+ 4 - 0
src/test/java/org/elasticsearch/index/search/child/ParentQueryTests.java

@@ -98,6 +98,10 @@ public class ParentQueryTests extends ElasticsearchLuceneTestCase {
             } else {
                 numChildDocs = random().nextInt(TEST_NIGHTLY ? 40 : 10);
             }
+            if (parentDocId == numParentDocs - 1 && childIdToParentId.isEmpty()) {
+                // ensure there is at least one child in the index
+                numChildDocs = Math.max(1, numChildDocs);
+            }
             for (int i = 0; i < numChildDocs; i++) {
                 String child = Integer.toString(childDocId++);
                 boolean markChildAsDeleted = rarely();