Skip to content

Commit 8e20e0c

Browse files
tabs to spaces
1 parent d66d248 commit 8e20e0c

File tree

1 file changed

+70
-70
lines changed

1 file changed

+70
-70
lines changed

test/explicit-resource-management/main.test.ts

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,79 @@ import { pipeline } from 'stream/promises';
66
import { setTimeout } from 'timers/promises';
77

88
async function setUpCollection(client: MongoClient) {
9-
const collection = client.db('foo').collection<{ name: string }>('bar');
10-
const documents: Array<{ name: string }> = Array.from({ length: 5 }).map(i => ({
11-
name: String(i)
12-
}));
13-
await collection.insertMany(documents)
14-
return collection;
9+
const collection = client.db('foo').collection<{ name: string }>('bar');
10+
const documents: Array<{ name: string }> = Array.from({ length: 5 }).map(i => ({
11+
name: String(i)
12+
}));
13+
await collection.insertMany(documents)
14+
return collection;
1515
}
1616

1717
describe('explicit resource management smoke tests', function () {
18-
describe('MongoClient', function () {
19-
it('does not crash or error when used with await-using syntax', async function () {
18+
describe('MongoClient', function () {
19+
it('does not crash or error when used with await-using syntax', async function () {
2020
await using client = new MongoClient(process.env.MONGODB_URI!);
2121
await client.connect();
22-
})
23-
})
24-
25-
describe('Cursors', function () {
26-
it('does not crash or error when used with await-using syntax', async function () {
27-
await using client = new MongoClient(process.env.MONGODB_URI!);
28-
await client.connect();
29-
30-
const collection = await setUpCollection(client);
31-
32-
await using cursor = collection.find();
33-
await cursor.next();
34-
await cursor.next();
35-
await cursor.next();
36-
})
37-
38-
describe('cursor streams', function() {
39-
it('does not crash or error when used with await-using syntax', async function() {
40-
await using client = new MongoClient(process.env.MONGODB_URI!);
41-
await client.connect();
42-
43-
const collection = await setUpCollection(client);
44-
45-
await using readable = collection.find().stream();
46-
})
47-
})
48-
})
49-
50-
describe('Sessions', function () {
51-
it('does not crash or error when used with await-using syntax', async function () {
52-
await using client = new MongoClient(process.env.MONGODB_URI!);
53-
await client.connect();
54-
55-
await using session = client.startSession();
56-
})
57-
})
58-
59-
describe('ChangeStreams', function () {
60-
it('does not crash or error when used with await-using syntax', async function () {
61-
await using client = new MongoClient(process.env.MONGODB_URI!);
62-
await client.connect();
63-
64-
const collection = await setUpCollection(client);
65-
await using cs = collection.watch();
66-
67-
setTimeout(1000).then(() => collection.insertOne({ name: 'bailey' }));
68-
await cs.next();
69-
})
70-
});
71-
72-
describe('GridFSDownloadStream', function () {
73-
it('does not crash or error when used with await-using syntax', async function () {
74-
await using client = new MongoClient(process.env.MONGODB_URI!);
75-
await client.connect();
76-
77-
const bucket = new GridFSBucket(client.db('foo'));
78-
const uploadStream = bucket.openUploadStream('foo.txt')
79-
await pipeline(Readable.from("AAAAAAA".split('')), uploadStream);
80-
81-
await using downloadStream = bucket.openDownloadStreamByName('foo.txt');
82-
})
83-
});
22+
})
23+
})
24+
25+
describe('Cursors', function () {
26+
it('does not crash or error when used with await-using syntax', async function () {
27+
await using client = new MongoClient(process.env.MONGODB_URI!);
28+
await client.connect();
29+
30+
const collection = await setUpCollection(client);
31+
32+
await using cursor = collection.find();
33+
await cursor.next();
34+
await cursor.next();
35+
await cursor.next();
36+
})
37+
38+
describe('cursor streams', function() {
39+
it('does not crash or error when used with await-using syntax', async function() {
40+
await using client = new MongoClient(process.env.MONGODB_URI!);
41+
await client.connect();
42+
43+
const collection = await setUpCollection(client);
44+
45+
await using readable = collection.find().stream();
46+
})
47+
})
48+
})
49+
50+
describe('Sessions', function () {
51+
it('does not crash or error when used with await-using syntax', async function () {
52+
await using client = new MongoClient(process.env.MONGODB_URI!);
53+
await client.connect();
54+
55+
await using session = client.startSession();
56+
})
57+
})
58+
59+
describe('ChangeStreams', function () {
60+
it('does not crash or error when used with await-using syntax', async function () {
61+
await using client = new MongoClient(process.env.MONGODB_URI!);
62+
await client.connect();
63+
64+
const collection = await setUpCollection(client);
65+
await using cs = collection.watch();
66+
67+
setTimeout(1000).then(() => collection.insertOne({ name: 'bailey' }));
68+
await cs.next();
69+
})
70+
});
71+
72+
describe('GridFSDownloadStream', function () {
73+
it('does not crash or error when used with await-using syntax', async function () {
74+
await using client = new MongoClient(process.env.MONGODB_URI!);
75+
await client.connect();
76+
77+
const bucket = new GridFSBucket(client.db('foo'));
78+
const uploadStream = bucket.openUploadStream('foo.txt')
79+
await pipeline(Readable.from("AAAAAAA".split('')), uploadStream);
80+
81+
await using downloadStream = bucket.openDownloadStreamByName('foo.txt');
82+
})
83+
});
8484
})

0 commit comments

Comments
 (0)