Skip to content

Commit

Permalink
Fixes tests in 4.0 as well, remove debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoBernardino committed Apr 1, 2022
1 parent ec53b77 commit 1cce859
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
34 changes: 8 additions & 26 deletions tests/cases/03_curd.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { MongoInvalidArgumentError } from "../../src/error.ts";
import { testWithClient, testWithTestDBClient } from "../common.ts";
import {
assert,
assertEquals,
AssertionError,
assertRejects,
semver,
} from "../test.deps.ts";
import { assert, assertEquals, assertRejects } from "../test.deps.ts";

interface IUser {
username?: string;
Expand Down Expand Up @@ -585,11 +579,7 @@ testWithTestDBClient("testFindEmptyAsyncIteration", async (db) => {
await db.collection("mongo_test_users").drop();
});

testWithClient("testFindWithMaxTimeMS", async (client) => {
const db = client.database("test");

const supportsMaxTimeMS = semver.gte(client.buildInfo!.version, "4.2.0");

testWithTestDBClient("testFindWithMaxTimeMS", async (db) => {
const users = db.collection<IUser>("mongo_test_users");
for (let i = 0; i < 10; i++) {
await users.insertOne({
Expand Down Expand Up @@ -617,13 +607,9 @@ testWithClient("testFindWithMaxTimeMS", async (client) => {
}, { maxTimeMS: 1 }).toArray();
assert(false);
} catch (e) {
if (supportsMaxTimeMS) {
assertEquals(e.codeName, "MaxTimeMSExpired");
assertEquals(e.errmsg, "operation exceeded time limit");
} else {
console.log(e.toString());
assert(e instanceof AssertionError);
}
assertEquals(e.ok, 0);
assertEquals(e.codeName, "MaxTimeMSExpired");
assertEquals(e.errmsg, "operation exceeded time limit");
}

try {
Expand All @@ -633,13 +619,9 @@ testWithClient("testFindWithMaxTimeMS", async (client) => {
}, { maxTimeMS: 1 });
assert(false);
} catch (e) {
if (supportsMaxTimeMS) {
assertEquals(e.codeName, "MaxTimeMSExpired");
assertEquals(e.errmsg, "operation exceeded time limit");
} else {
console.log(e.toString());
assert(e instanceof AssertionError);
}
assertEquals(e.ok, 0);
assertEquals(e.codeName, "MaxTimeMSExpired");
assertEquals(e.errmsg, "operation exceeded time limit");
}

await db.collection("mongo_test_users").drop();
Expand Down
1 change: 0 additions & 1 deletion tests/test.deps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export {
assert,
assertEquals,
AssertionError,
assertNotEquals,
assertRejects,
assertThrows,
Expand Down

0 comments on commit 1cce859

Please sign in to comment.