Skip to content

Commit 3289efe

Browse files
committed
Make map and reduce functions more realistic in mapReduce collation test
The functions that were used exposed a subtle difference in server behavior that the test was not intending to exercise. This change ensures that the map and reduce functions will behave consistently on all server versions JAVA-3555
1 parent 038fc6f commit 3289efe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceWithInlineResultsOperationSpecification.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,17 @@ class MapReduceWithInlineResultsOperationSpecification extends OperationFunction
237237
getCollectionHelper().insertDocuments(document)
238238
def operation = new MapReduceWithInlineResultsOperation<BsonDocument>(
239239
namespace,
240-
new BsonJavaScript('function(){ emit( this._id, this.str ); }'),
241-
new BsonJavaScript('function(key, values){ return key, values; }'),
240+
new BsonJavaScript('function(){ emit( this.str, 1 ); }'),
241+
new BsonJavaScript('function(key, values){ return Array.sum(values); }'),
242242
bsonDocumentCodec)
243243
.filter(BsonDocument.parse('{str: "FOO"}'))
244244
.collation(caseInsensitiveCollation)
245245

246246
when:
247-
def results = executeAndCollectBatchCursorResults(operation, async) as Set
247+
def results = executeAndCollectBatchCursorResults(operation, async)
248248

249249
then:
250-
results == [Document.parse('{_id: 1.0, value: "foo"}')]
250+
results == [new BsonDocument('_id', new BsonString('foo')).append('value', new BsonDouble(1))]
251251

252252
where:
253253
async << [true, false]

0 commit comments

Comments
 (0)