Skip to content

Commit ea45d50

Browse files
author
Justin Lee
committed
fix failing tests by enforcing an order
1 parent d7c34c0 commit ea45d50

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

driver-core/src/test/functional/com/mongodb/client/model/AggregatesFunctionalSpecification.groovy

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,23 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
251251
def lookupDoc = graphLookup('contacts', new BsonString('$friends'), 'friends', 'name', 'socialNetwork')
252252

253253
when:
254-
def results = fromHelper.aggregate([lookupDoc])
254+
def results = fromHelper.aggregate([lookupDoc,
255+
unwind('$socialNetwork'),
256+
sort(new Document('_id', 1).append('socialNetwork._id', 1))])
255257

256258
then:
257-
results[0] ==
258-
Document.parse('''{
259-
_id: 0,
260-
name: "Bob Smith",
261-
friends: ["Anna Jones", "Chris Green"],
262-
socialNetwork: [
263-
{ _id: 3, name: "Joe Lee", friends: ["Anna Jones", "Fred Brown" ] },
264-
{ _id: 4, name: "Fred Brown", friends: ["Joe Lee"] },
265-
{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"] },
266-
{ _id: 2, name: "Chris Green", friends: ["Anna Jones", "Bob Smith"] },
267-
{ _id: 1, name: "Anna Jones", friends: ["Bob Smith", "Chris Green", "Joe Lee"] }
268-
]
269-
}''')
259+
results.subList(0, 5) == [
260+
Document.parse('''{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], socialNetwork: {
261+
_id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"] } }'''),
262+
Document.parse('''{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], socialNetwork: {
263+
_id: 1, name: "Anna Jones", friends: ["Bob Smith", "Chris Green", "Joe Lee"] } }'''),
264+
Document.parse('''{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], socialNetwork: {
265+
_id: 2, name: "Chris Green", friends: ["Anna Jones", "Bob Smith"] } }'''),
266+
Document.parse('''{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], socialNetwork: {
267+
_id: 3, name: "Joe Lee", friends: ["Anna Jones", "Fred Brown" ] } }'''),
268+
Document.parse('''{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], socialNetwork: {
269+
_id: 4, name: "Fred Brown", friends: ["Joe Lee"] } }''')
270+
]
270271

271272
cleanup:
272273
fromHelper?.drop()
@@ -292,21 +293,22 @@ class AggregatesFunctionalSpecification extends OperationFunctionalSpecification
292293
.depthField('depth'))
293294

294295
when:
295-
def results = fromHelper.aggregate([lookupDoc])
296+
def results = fromHelper.aggregate([lookupDoc,
297+
unwind('$socialNetwork'),
298+
sort(new Document('_id', 1)
299+
.append('socialNetwork._id', 1))])
296300

297301
then:
298-
results[0] ==
299-
Document.parse('''{
300-
_id: 0,
301-
name: "Bob Smith",
302-
friends: ["Anna Jones", "Chris Green"],
303-
socialNetwork: [
304-
{ _id: 3, name: "Joe Lee", friends: ["Anna Jones", "Fred Brown" ], depth:1 },
305-
{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], depth:1 },
306-
{ _id: 2, name: "Chris Green", friends: ["Anna Jones", "Bob Smith"], depth:0 },
307-
{ _id: 1, name: "Anna Jones", friends: ["Bob Smith", "Chris Green", "Joe Lee"], depth:0 }
308-
]
309-
}''')
302+
results.subList(0, 4) == [
303+
Document.parse('''{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], socialNetwork: {
304+
_id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], depth:1 } }'''),
305+
Document.parse('''{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], socialNetwork: {
306+
_id: 1, name: "Anna Jones", friends: ["Bob Smith", "Chris Green", "Joe Lee"], depth:0 } }'''),
307+
Document.parse('''{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], socialNetwork: {
308+
_id: 2, name: "Chris Green", friends: ["Anna Jones", "Bob Smith"], depth:0 } }'''),
309+
Document.parse('''{ _id: 0, name: "Bob Smith", friends: ["Anna Jones", "Chris Green"], socialNetwork: {
310+
_id: 3, name: "Joe Lee", friends: ["Anna Jones", "Fred Brown" ], depth:1 } }''')
311+
]
310312

311313
cleanup:
312314
fromHelper?.drop()

0 commit comments

Comments
 (0)