Skip to content

Commit 5ef7f9c

Browse files
committed
Make tests resilient to "ns not found" not being at the start of the error message
1 parent 8b5ccdd commit 5ef7f9c

File tree

3 files changed

+5
-5
lines changed
  • driver-core/src/test/functional/com/mongodb/internal/async/client
  • driver-reactive-streams/src/test

3 files changed

+5
-5
lines changed

driver-core/src/test/functional/com/mongodb/internal/async/client/Fixture.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static AsyncMongoCollection<Document> initializeCollection(final MongoNam
9595
database.runCommand(new Document("drop", namespace.getCollectionName()), futureResultCallback);
9696
futureResultCallback.get();
9797
} catch (MongoCommandException e) {
98-
if (!e.getErrorMessage().startsWith("ns not found")) {
98+
if (!e.getErrorMessage().contains("ns not found")) {
9999
throw e;
100100
}
101101
} catch (Throwable t) {
@@ -119,7 +119,7 @@ public static void dropDatabase(final String name) {
119119
.runCommand(new Document("dropDatabase", 1), futureResultCallback);
120120
futureResultCallback.get();
121121
} catch (MongoCommandException e) {
122-
if (!e.getErrorMessage().startsWith("ns not found")) {
122+
if (!e.getErrorMessage().contains("ns not found")) {
123123
throw e;
124124
}
125125
} catch (Throwable t) {

driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/Fixture.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static MongoCollection<Document> initializeCollection(final MongoNamespac
8181
database.runCommand(new Document("drop", namespace.getCollectionName())).subscribe(subscriber);
8282
subscriber.await(10, SECONDS);
8383
} catch (MongoCommandException e) {
84-
if (!e.getErrorMessage().startsWith("ns not found")) {
84+
if (!e.getErrorMessage().contains("ns not found")) {
8585
throw e;
8686
}
8787
}
@@ -97,7 +97,7 @@ public static void dropDatabase(final String name) throws Throwable {
9797
getMongoClient().getDatabase(name).runCommand(new Document("dropDatabase", 1)).subscribe(subscriber);
9898
subscriber.await(10, SECONDS);
9999
} catch (MongoCommandException e) {
100-
if (!e.getErrorMessage().startsWith("ns not found")) {
100+
if (!e.getErrorMessage().contains("ns not found")) {
101101
throw e;
102102
}
103103
}

driver-reactive-streams/src/test/tck/com/mongodb/reactivestreams/client/MongoFixture.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static void dropDatabase(final String name) {
7777
try {
7878
run(getMongoClient().getDatabase(name).runCommand(new Document("dropDatabase", 1)));
7979
} catch (MongoCommandException e) {
80-
if (!e.getErrorMessage().startsWith("ns not found")) {
80+
if (!e.getErrorMessage().contains("ns not found")) {
8181
throw e;
8282
}
8383
}

0 commit comments

Comments
 (0)