Skip to content

Commit d66d248

Browse files
comments pt 2
1 parent 8c75a58 commit d66d248

File tree

5 files changed

+47
-83
lines changed

5 files changed

+47
-83
lines changed

.evergreen/config.in.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ functions:
365365
args:
366366
- "${PROJECT_DIRECTORY}/.evergreen/run-resource-management.sh"
367367

368-
"check resource management smoke tests":
368+
"check resource management feature integration":
369369
- command: subprocess.exec
370370
type: test
371371
params:

.evergreen/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ functions:
327327
binary: bash
328328
args:
329329
- ${PROJECT_DIRECTORY}/.evergreen/run-resource-management.sh
330-
check resource management smoke tests:
330+
check resource management feature integration:
331331
- command: subprocess.exec
332332
type: test
333333
params:
@@ -3508,7 +3508,7 @@ tasks:
35083508
- {key: NPM_VERSION, value: '9'}
35093509
- func: install dependencies
35103510
- func: check resource management
3511-
- name: test-explicit-resource-management-smoke-tests
3511+
- name: test-explicit-resource-management-feature-integration
35123512
tags:
35133513
- resource-management
35143514
commands:
@@ -3521,7 +3521,7 @@ tasks:
35213521
- {key: NODE_LTS_VERSION, value: latest}
35223522
- func: install dependencies
35233523
- func: bootstrap mongo-orchestration
3524-
- func: check resource management smoke tests
3524+
- func: check resource management feature integration
35253525
- name: check-types-typescript-next-node-types-20.14.10
35263526
tags:
35273527
- check-types-typescript-next

.evergreen/generate_evergreen_tasks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ SINGLETON_TASKS.push(
517517
]
518518
},
519519
{
520-
name: 'test-explicit-resource-management-smoke-tests',
520+
name: 'test-explicit-resource-management-feature-integration',
521521
tags: ['resource-management'],
522522
commands: [
523523
updateExpansions({
@@ -527,7 +527,7 @@ SINGLETON_TASKS.push(
527527
}),
528528
{ func: 'install dependencies' },
529529
{ func: 'bootstrap mongo-orchestration' },
530-
{ func: 'check resource management smoke tests' }
530+
{ func: 'check resource management feature integration' }
531531
]
532532
},
533533
...Array.from(makeTypescriptTasks())
Lines changed: 40 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

2-
import { expect } from 'chai';
32
import { describe, it } from 'mocha';
4-
import { AbstractCursor, ChangeStream, ClientSession, GridFSBucket, MongoClient } from 'mongodb/lib/beta';
5-
import * as sinon from 'sinon';
3+
import { GridFSBucket, MongoClient } from 'mongodb/lib/beta';
64
import { Readable } from 'stream';
75
import { pipeline } from 'stream/promises';
86
import { setTimeout } from 'timers/promises';
@@ -17,104 +15,70 @@ async function setUpCollection(client: MongoClient) {
1715
}
1816

1917
describe('explicit resource management smoke tests', function () {
20-
const clientSpy = sinon.spy(MongoClient.prototype, Symbol.asyncDispose);
21-
const cursorSpy = sinon.spy(AbstractCursor.prototype, Symbol.asyncDispose);
22-
const endSessionSpy = sinon.spy(ClientSession.prototype, Symbol.asyncDispose);
23-
const changeStreamSpy = sinon.spy(ChangeStream.prototype, Symbol.asyncDispose);
24-
const readableSpy = sinon.spy(Readable.prototype, Symbol.asyncDispose);
25-
26-
afterEach(function () {
27-
clientSpy.resetHistory();
28-
cursorSpy.resetHistory();
29-
endSessionSpy.resetHistory();
30-
changeStreamSpy.resetHistory();
31-
readableSpy.resetHistory();
32-
});
33-
3418
describe('MongoClient', function () {
35-
it('can be used with await-using syntax', async function () {
36-
{
37-
await using client = new MongoClient(process.env.MONGODB_URI!);
38-
await client.connect();
39-
}
40-
expect(clientSpy.called).to.be.true;
41-
expect(clientSpy.callCount).to.equal(1);
19+
it('does not crash or error when used with await-using syntax', async function () {
20+
await using client = new MongoClient(process.env.MONGODB_URI!);
21+
await client.connect();
4222
})
4323
})
4424

4525
describe('Cursors', function () {
46-
it('can be used with await-using syntax', async function () {
47-
{
48-
await using client = new MongoClient(process.env.MONGODB_URI!);
49-
await client.connect();
50-
51-
const collection = await setUpCollection(client);
52-
53-
await using cursor = collection.find();
54-
await cursor.next();
55-
await cursor.next();
56-
await cursor.next();
57-
}
58-
expect(cursorSpy.callCount).to.equal(1);
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();
5936
})
6037

6138
describe('cursor streams', function() {
62-
it('can be used with await-using syntax', async function() {
63-
{
64-
await using client = new MongoClient(process.env.MONGODB_URI!);
65-
await client.connect();
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();
6642

67-
const collection = await setUpCollection(client);
43+
const collection = await setUpCollection(client);
6844

69-
await using readable = collection.find().stream();
70-
}
71-
expect(readableSpy.callCount).to.equal(1);
45+
await using readable = collection.find().stream();
7246
})
7347
})
7448
})
7549

7650
describe('Sessions', function () {
77-
it('can be used with await-using syntax', async function () {
78-
{
79-
await using client = new MongoClient(process.env.MONGODB_URI!);
80-
await client.connect();
81-
82-
await using session = client.startSession();
83-
}
84-
expect(endSessionSpy.callCount).to.equal(1);
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();
8556
})
8657
})
8758

8859
describe('ChangeStreams', function () {
89-
it('can be used with await-using syntax', async function () {
90-
{
91-
await using client = new MongoClient(process.env.MONGODB_URI!);
92-
await client.connect();
93-
94-
const collection = await setUpCollection(client);
95-
await using cs = collection.watch();
96-
97-
setTimeout(1000).then(() => collection.insertOne({ name: 'bailey' }));
98-
await cs.next();
99-
}
100-
expect(changeStreamSpy.callCount).to.equal(1);
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();
10169
})
10270
});
10371

10472
describe('GridFSDownloadStream', function () {
105-
it('can be used with await-using syntax', async function () {
106-
{
107-
await using client = new MongoClient(process.env.MONGODB_URI!);
108-
await client.connect();
109-
110-
const bucket = new GridFSBucket(client.db('foo'));
111-
const uploadStream = bucket.openUploadStream('foo.txt')
112-
await pipeline(Readable.from("AAAAAAA".split('')), uploadStream);
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();
11376

114-
await using downloadStream = bucket.openDownloadStreamByName('foo.txt');
77+
const bucket = new GridFSBucket(client.db('foo'));
78+
const uploadStream = bucket.openUploadStream('foo.txt')
79+
await pipeline(Readable.from("AAAAAAA".split('')), uploadStream);
11580

116-
}
117-
expect(readableSpy.callCount).to.equal(1);
81+
await using downloadStream = bucket.openDownloadStreamByName('foo.txt');
11882
})
11983
});
12084
})

test/manual/resource_management.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as sinon from 'sinon';
33

44
import { AbstractCursor, ChangeStream, ClientSession, MongoClient } from '../mongodb';
55

6-
describe('Explicit Resource Management Tests', function () {
6+
describe('Symbol.asyncDispose implementation tests', function () {
77
let client: MongoClient;
88

99
afterEach(async function () {

0 commit comments

Comments
 (0)