Skip to content

Commit

Permalink
test: to ensure multiple concurrent operations can be performed throu…
Browse files Browse the repository at this point in the history
…gh the mongo driver

Helps hedge against this issue denoland/deno#19831
  • Loading branch information
TillaTheHun0 committed Nov 1, 2023
1 parent 1adf190 commit 5d2d8fa
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}

Expand Down Expand Up @@ -101,4 +101,4 @@ jobs:
- name: 🦕 Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
deno-version: 1.x
47 changes: 47 additions & 0 deletions test/suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 5d2d8fa

Please sign in to comment.