Skip to content

Commit 785df92

Browse files
committed
Skip test that requires a secondary when running against a single node replica set.
1 parent 8641f80 commit 785df92

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/MongoDB.Driver.Legacy.Tests/MongoCollectionTests.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,17 @@ public void TestCountWithQuery()
478478
[SkippableFact]
479479
public void TestCountWithReadPreferenceFromFind()
480480
{
481-
RequireServer.Check();
482-
_collection.Drop();
481+
RequireServer.Check().ClusterType(ClusterType.ReplicaSet);
483482
var all = LegacyTestConfiguration.Server.Secondaries.Length + 1;
484-
var options = new MongoInsertOptions { WriteConcern = new WriteConcern(w: all) };
485-
_collection.Insert(new BsonDocument("x", 1), options);
486-
_collection.Insert(new BsonDocument("x", 2), options);
487-
var count = _collection.Find(Query.EQ("x", 1)).SetReadPreference(ReadPreference.Secondary).Count();
488-
Assert.Equal(1, count);
483+
if (all > 1)
484+
{
485+
_collection.Drop();
486+
var options = new MongoInsertOptions { WriteConcern = new WriteConcern(w: all) };
487+
_collection.Insert(new BsonDocument("x", 1), options);
488+
_collection.Insert(new BsonDocument("x", 2), options);
489+
var count = _collection.Find(Query.EQ("x", 1)).SetReadPreference(ReadPreference.Secondary).Count();
490+
Assert.Equal(1, count);
491+
}
489492
}
490493

491494
[SkippableFact]

0 commit comments

Comments
 (0)