From 5d2d8fab6bf465057ac1678f54b53d5915a11c80 Mon Sep 17 00:00:00 2001 From: Tyler Hall Date: Wed, 1 Nov 2023 12:48:14 +0000 Subject: [PATCH] test: to ensure multiple concurrent operations can be performed through the mongo driver Helps hedge against this issue https://github.com/denoland/deno/issues/19831 --- .github/workflows/test-and-publish.yml | 6 ++-- test/suite.ts | 47 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml index b57a7ad..8ea3cc0 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/test-and-publish.yml @@ -40,7 +40,7 @@ jobs: strategy: matrix: deno-version: [1.x] - mongodb-version: [6] + mongodb-version: [7] steps: - name: ⬇️ Checkout repo uses: actions/checkout@v3 @@ -52,7 +52,7 @@ jobs: # Start a Mongo Instance in the local CI runner environment - name: Start MongoDB - uses: supercharge/mongodb-github-action@1.9.0 + uses: supercharge/mongodb-github-action@1.10.0 with: mongodb-version: ${{ matrix.mongodb-version }} @@ -101,4 +101,4 @@ jobs: - name: 🦕 Setup Deno uses: denoland/setup-deno@v1 with: - deno-version: v1.x + deno-version: 1.x diff --git a/test/suite.ts b/test/suite.ts index 27095f3..5a863ec 100644 --- a/test/suite.ts +++ b/test/suite.ts @@ -428,6 +428,53 @@ async ( }, ) + /** + * Test to ensure the issue described in https://github.com/denoland/deno/issues/19831 + * is fixed in newest versions of deno + */ + await t.step('can handle mulitple concurrent operations', async () => { + await a.createDatabase(DB) + + await a.createDocument({ + db: DB, + id: '10-caddyshack', + doc: { title: 'Caddyshack', year: '1978', genre: ['comedy'] }, + }) + + await a.createDocument({ + db: DB, + id: '12-ghostbusters', + doc: { title: 'Ghostbusters', year: '1980', genre: ['comedy'] }, + }) + + await a.createDocument({ + db: DB, + id: '15-starwars', + doc: { title: 'Star Wars', year: '1976', genre: ['sci-fi'] }, + }) + + await a.createDocument({ + db: DB, + id: '17-jaws', + doc: { title: 'Jaws', year: '1977', genre: ['drama'] }, + }) + + await Promise.all( + Array(10).fill('').map(() => + a.queryDocuments({ + db: DB, + query: { + selector: { year: { $lte: '1978' } }, + fields: ['_id', 'genre', 'year'], + sort: [{ title: 'DESC' }, { year: 'DESC' }], + }, + }).then((res) => assertObjectMatch(res as any, { ok: true })) + ), + ) + + await a.removeDatabase(DB) + }) + await t.step( 'should return a HyperErr(404) if the database does not exist', async () => {