Skip to content

Commit

Permalink
chore: bump dependencies and refactor usages. Latest mongo in-memory …
Browse files Browse the repository at this point in the history
…server defaults to [email protected]
  • Loading branch information
TillaTheHun0 committed Aug 19, 2024
1 parent d2fbb94 commit e121164
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 15 deletions.
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

deno task staged
2 changes: 1 addition & 1 deletion adapter.memory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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()
const { client } = await mongo({ dir: '__hyper__', dirVersion: '7.0.11' }).load()
await suite(t)(client, { shouldBaseLine: true })
},
/**
Expand Down
41 changes: 40 additions & 1 deletion clients/atlas-data.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
import { assertEquals, assertObjectMatch, assertThrows, deferred } from '../dev_deps.ts'
import { assertEquals, assertObjectMatch, assertThrows } from '../dev_deps.ts'

import { AtlasDataClient } from './atlas-data.ts'

interface Deferred<T> extends Promise<T> {
readonly state: 'pending' | 'fulfilled' | 'rejected'
resolve(value?: T | PromiseLike<T>): void
// deno-lint-ignore no-explicit-any
reject(reason?: any): void
}

/**
* Creates a Promise with the `reject` and `resolve` functions placed as methods
* on the promise object itself.
*
* @example
* ```typescript
* const p = deferred<number>();
* // ...
* p.resolve(42);
* ```
*/
function deferred<T>(): Deferred<T> {
let methods
let state = 'pending'
const promise = new Promise<T>((resolve, reject) => {
methods = {
async resolve(value: T | PromiseLike<T>) {
await value
state = 'fulfilled'
resolve(value)
},
// deno-lint-ignore no-explicit-any
reject(reason?: any) {
state = 'rejected'
reject(reason)
},
}
})
Object.defineProperty(promise, 'state', { get: () => state })
return Object.assign(promise, methods) as Deferred<T>
}

Deno.test('client - atlas-data', async (t) => {
let fetchMock = deferred<{ url: string; init: RequestInit }>()

Expand Down
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tasks": {
"prepare": "deno run -A --no-lock npm:husky@^8 install",
"prepare": "deno run -A --no-lock npm:husky@^9",
"staged": "deno run -A --no-lock npm:lint-staged@^15",
"cache": "deno cache --lock=deno.lock --lock-write deps.ts dev_deps.ts",
"test": "deno lint && deno fmt --check && deno test -A --no-lock --unstable --ignore='*.integration.test.ts'",
Expand Down
212 changes: 212 additions & 0 deletions deno.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export { default as crocks } from 'npm:[email protected]'
// @deno-types="npm:@types/ramda@^0.29.9"
export * as R from 'npm:[email protected]'

export { EJSON } from 'npm:bson@6.2.0'
export { type Collection, MongoClient } from 'npm:mongodb@6.3.0'
export { EJSON } from 'npm:bson@6.8.0'
export { type Collection, MongoClient } from 'npm:mongodb@6.8.0'
export { default as cuid } from 'npm:[email protected]'
export { MongoMemoryServer } from 'npm:mongodb-memory-server-core@9.1.1'
export { MongoMemoryServer } from 'npm:mongodb-memory-server-core@10.0.0'

export { join } from 'https://deno.land/std@0.208.0/path/mod.ts'
export { join } from 'https://deno.land/std@0.224.0/path/mod.ts'

import {
HyperErr,
Expand Down
5 changes: 2 additions & 3 deletions dev_deps.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
export { default as pluginFactory } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper%40v4.3.2/packages/core/utils/plugin-schema.ts'
export { default as pluginFactory } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper%40v4.3.3/packages/core/utils/plugin-schema.ts'
export { data as dataPort } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper-port-data%40v2.3.0/packages/port-data/mod.ts'

// std lib deps
export { deferred } from 'https://deno.land/[email protected]/async/deferred.ts'
export {
assert,
assertEquals,
assertObjectMatch,
assertRejects,
assertThrows,
} from 'https://deno.land/std@0.208.0/assert/mod.ts'
} from 'https://deno.land/std@0.224.0/assert/mod.ts'
3 changes: 1 addition & 2 deletions utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { HyperErr } from 'https://raw.githubusercontent.com/hyper63/hyper/hyper-utils%40v0.1.0/packages/utils/hyper-err.js'
import { isHyperErr } from './deps.ts'
import { HyperErr, isHyperErr } from './deps.ts'
import { assert, assertEquals, assertObjectMatch } from './dev_deps.ts'

import { mapSort, mongoErrToHyperErr, queryOptions, toBulkOperations } from './utils.ts'
Expand Down

0 comments on commit e121164

Please sign in to comment.