-
-
Notifications
You must be signed in to change notification settings - Fork 96
/
10_command_helpers.ts
31 lines (25 loc) 路 997 Bytes
/
10_command_helpers.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { MongoClient } from "../../mod.ts";
import { assert, assertEquals, describe, it } from "../deps.ts";
describe("command helpers", () => {
it({
name: "db.dropDatabase",
fn: async () => {
const client = new MongoClient();
const databaseName = `TEST_DATABASE_MUST_NOT_MATCH_${+new Date()}`;
const db = await client.connect(
`mongodb://127.0.0.1:27017/${databaseName}`,
);
const collectioName = `${databaseName}_collection`;
// To create database physically
await db.createCollection<{ foo: string }>(`${collectioName}`);
// A sanity check to test existence of the collection inside the test db
assertEquals((await db.listCollectionNames()).length, 1);
const result = await db.dropDatabase();
assert(result);
assertEquals(result.ok, 1);
// The collection inside the test db must not exist
assertEquals((await db.listCollectionNames()).length, 0);
client.close();
},
});
});