Skip to content

Commit af121ae

Browse files
committed
Fix Count hint tests
Added version check JAVA-2885
1 parent 3e27769 commit af121ae

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class CountOperationSpecification extends OperationFunctionalSpecification {
178178
[async, strategy] << [[true, false], [CountStrategy.AGGREGATE, CountStrategy.COMMAND]].combinations()
179179
}
180180

181+
@IgnoreIf({ !serverVersionAtLeast(3, 6) })
181182
def 'should use hint with the count'() {
182183
given:
183184
def indexDefinition = new BsonDocument('y', new BsonInt32(1))
@@ -189,13 +190,23 @@ class CountOperationSpecification extends OperationFunctionalSpecification {
189190
def count = execute(operation, async)
190191

191192
then:
192-
count == (serverVersionAtLeast(3, 4) ? 1 : documents.size())
193+
count == 1
193194

194195
where:
195196
[async, strategy] << [[true, false], [CountStrategy.AGGREGATE, CountStrategy.COMMAND]].combinations()
196197
}
197198

198-
def 'should throw with bad hint with mongod 2.6+'() {
199+
@IgnoreIf({ !serverVersionAtLeast(3, 6) })
200+
def 'should support hints that are bson documents or strings'() {
201+
expect:
202+
execute(new CountOperation(getNamespace(), strategy).hint(hint), async) == 5
203+
204+
where:
205+
[async, strategy, hint] << [[true, false], [CountStrategy.AGGREGATE, CountStrategy.COMMAND],
206+
[new BsonString('_id_'), BsonDocument.parse('{_id: 1}')]].combinations()
207+
}
208+
209+
def 'should throw with bad hint'() {
199210
given:
200211
def operation = new CountOperation(getNamespace(), strategy)
201212
.filter(new BsonDocument('a', new BsonInt32(1)))
@@ -211,15 +222,6 @@ class CountOperationSpecification extends OperationFunctionalSpecification {
211222
[async, strategy] << [[true, false], [CountStrategy.AGGREGATE, CountStrategy.COMMAND]].combinations()
212223
}
213224

214-
def 'should support hints that are bson documents or strings'() {
215-
expect:
216-
execute(new CountOperation(getNamespace(), strategy).hint(hint), async) == 5
217-
218-
where:
219-
[async, strategy, hint] << [[true, false], [CountStrategy.AGGREGATE, CountStrategy.COMMAND],
220-
[new BsonString('_id_'), BsonDocument.parse('{_id: 1}')]].combinations()
221-
}
222-
223225
@IgnoreIf({ !serverVersionAtLeast(3, 0) || isSharded() })
224226
def 'should explain'() {
225227
when:

0 commit comments

Comments
 (0)