Skip to content

Commit

Permalink
test: add adapter.memory that uses in-memory mongo to run test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Dec 1, 2023
1 parent 1775aca commit 60588f6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
22 changes: 22 additions & 0 deletions adapter.memory.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import mongo from './mod.ts'

import { suite } from './test/suite.ts'

Deno.test({
name: 'Mongo Adapter Test Suite - In-Memory',
fn: async (t) => {
const { client } = await mongo({ dir: '__hyper__', dirVersion: '7.0.4' }).load()
await suite(t)(client, { shouldBaseLine: true })
},
/**
* The native client maintains TCP connections
* and timers, as part of connecting to Mongo,
*
* So we ignore sanitization of these resources
* and ops, when running tests with the NativeClient
*
* See https://deno.com/manual/basics/testing/sanitizers
*/
sanitizeOps: false,
sanitizeResources: false,
})
4 changes: 2 additions & 2 deletions adapter.native.integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NativeClient } from './clients/native.ts'
import mongo from './mod.ts'

import { suite } from './test/suite.ts'

Expand All @@ -10,7 +10,7 @@ Deno.test({
throw new Error('MongoDB connection string is required at MONGO_URL')
}

const client = new NativeClient({ url })
const { client } = await mongo({ url }).load()
await suite(t)(client, { shouldBaseLine: true })
},
/**
Expand Down
1 change: 0 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default (config: AdapterConfig) => ({
instance: { dbPath: join(mongoMsDir, 'data'), storageEngine: 'wiredTiger' },
binary: { downloadDir: mongoMsDir, version: config.dirVersion },
}).then((mongod) => new URL(mongod.getUri()))
console.log(`In-Memory MongoDB: ${url.toString()}`)
} else {
url = new URL(config.url as string)
}
Expand Down

0 comments on commit 60588f6

Please sign in to comment.