From 8e20e0c60138c20b73b16370e35d9a2662da2473 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Tue, 30 Jul 2024 11:55:54 -0600 Subject: [PATCH] tabs to spaces --- .../explicit-resource-management/main.test.ts | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/test/explicit-resource-management/main.test.ts b/test/explicit-resource-management/main.test.ts index 0722e9ad8e..e65738a375 100644 --- a/test/explicit-resource-management/main.test.ts +++ b/test/explicit-resource-management/main.test.ts @@ -6,79 +6,79 @@ import { pipeline } from 'stream/promises'; import { setTimeout } from 'timers/promises'; async function setUpCollection(client: MongoClient) { - const collection = client.db('foo').collection<{ name: string }>('bar'); - const documents: Array<{ name: string }> = Array.from({ length: 5 }).map(i => ({ - name: String(i) - })); - await collection.insertMany(documents) - return collection; + const collection = client.db('foo').collection<{ name: string }>('bar'); + const documents: Array<{ name: string }> = Array.from({ length: 5 }).map(i => ({ + name: String(i) + })); + await collection.insertMany(documents) + return collection; } describe('explicit resource management smoke tests', function () { - describe('MongoClient', function () { - it('does not crash or error when used with await-using syntax', async function () { + describe('MongoClient', function () { + it('does not crash or error when used with await-using syntax', async function () { await using client = new MongoClient(process.env.MONGODB_URI!); await client.connect(); - }) - }) - - describe('Cursors', function () { - it('does not crash or error when used with await-using syntax', async function () { - await using client = new MongoClient(process.env.MONGODB_URI!); - await client.connect(); - - const collection = await setUpCollection(client); - - await using cursor = collection.find(); - await cursor.next(); - await cursor.next(); - await cursor.next(); - }) - - describe('cursor streams', function() { - it('does not crash or error when used with await-using syntax', async function() { - await using client = new MongoClient(process.env.MONGODB_URI!); - await client.connect(); - - const collection = await setUpCollection(client); - - await using readable = collection.find().stream(); - }) - }) - }) - - describe('Sessions', function () { - it('does not crash or error when used with await-using syntax', async function () { - await using client = new MongoClient(process.env.MONGODB_URI!); - await client.connect(); - - await using session = client.startSession(); - }) - }) - - describe('ChangeStreams', function () { - it('does not crash or error when used with await-using syntax', async function () { - await using client = new MongoClient(process.env.MONGODB_URI!); - await client.connect(); - - const collection = await setUpCollection(client); - await using cs = collection.watch(); - - setTimeout(1000).then(() => collection.insertOne({ name: 'bailey' })); - await cs.next(); - }) - }); - - describe('GridFSDownloadStream', function () { - it('does not crash or error when used with await-using syntax', async function () { - await using client = new MongoClient(process.env.MONGODB_URI!); - await client.connect(); - - const bucket = new GridFSBucket(client.db('foo')); - const uploadStream = bucket.openUploadStream('foo.txt') - await pipeline(Readable.from("AAAAAAA".split('')), uploadStream); - - await using downloadStream = bucket.openDownloadStreamByName('foo.txt'); - }) - }); + }) + }) + + describe('Cursors', function () { + it('does not crash or error when used with await-using syntax', async function () { + await using client = new MongoClient(process.env.MONGODB_URI!); + await client.connect(); + + const collection = await setUpCollection(client); + + await using cursor = collection.find(); + await cursor.next(); + await cursor.next(); + await cursor.next(); + }) + + describe('cursor streams', function() { + it('does not crash or error when used with await-using syntax', async function() { + await using client = new MongoClient(process.env.MONGODB_URI!); + await client.connect(); + + const collection = await setUpCollection(client); + + await using readable = collection.find().stream(); + }) + }) + }) + + describe('Sessions', function () { + it('does not crash or error when used with await-using syntax', async function () { + await using client = new MongoClient(process.env.MONGODB_URI!); + await client.connect(); + + await using session = client.startSession(); + }) + }) + + describe('ChangeStreams', function () { + it('does not crash or error when used with await-using syntax', async function () { + await using client = new MongoClient(process.env.MONGODB_URI!); + await client.connect(); + + const collection = await setUpCollection(client); + await using cs = collection.watch(); + + setTimeout(1000).then(() => collection.insertOne({ name: 'bailey' })); + await cs.next(); + }) + }); + + describe('GridFSDownloadStream', function () { + it('does not crash or error when used with await-using syntax', async function () { + await using client = new MongoClient(process.env.MONGODB_URI!); + await client.connect(); + + const bucket = new GridFSBucket(client.db('foo')); + const uploadStream = bucket.openUploadStream('foo.txt') + await pipeline(Readable.from("AAAAAAA".split('')), uploadStream); + + await using downloadStream = bucket.openDownloadStreamByName('foo.txt'); + }) + }); })