Skip to content

Commit

Permalink
upgrade to deno2, fixes pubkey#6739
Browse files Browse the repository at this point in the history
  • Loading branch information
jkinggg committed Jan 7, 2025
1 parent 3e8bfb7 commit 8bec337
Show file tree
Hide file tree
Showing 67 changed files with 72 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ jobs:
- uses: denoland/setup-deno@v1
with:
# https://github.com/denoland/deno/releases
deno-version: "1.46.3"
deno-version: "2.0.6"
- name: run deno tests:dexie
run: |
sudo npm i -g cross-env
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/test/ssr.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from 'assert';
import * as assert from 'node:assert';
import { waitUntil } from 'async-test-util';

const baseUrl = 'http://localhost:4200/';
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@
"test:node:memory-random-delay": "npm run transpile && cross-env DEFAULT_STORAGE=memory-random-delay mocha --expose-gc --config ./config/.mocharc.cjs ./test_tmp/unit.test.js",
"test:node:dexie": "npm run transpile && cross-env DEFAULT_STORAGE=dexie mocha --expose-gc --config ./config/.mocharc.cjs ./test_tmp/unit.test.js",
"test:bun:dexie": "npm run transpile && cross-env DEFAULT_STORAGE=dexie NODE_ENV=fast bun run ./node_modules/mocha/bin/mocha test_tmp/unit.test.js --bail",
"test:deno:dexie": "npm run transpile && cross-env DEFAULT_STORAGE=dexie deno run --unstable --allow-env --unstable-byonm --allow-read -A npm:mocha ./test/unit.test.ts --bail",
"test:deno:denokv": "npm run transpile && cross-env DEFAULT_STORAGE=denokv deno run --unstable-kv --unstable-broadcast-channel --allow-env --unstable-byonm --allow-read -A npm:mocha ./test/unit.test.ts --bail --timeout 15000",
"test:deno:dexie": "npm run transpile && cross-env DEFAULT_STORAGE=dexie deno run --unstable --unstable-broadcast-channel --unstable-byonm -A npm:mocha ./test/unit.test.ts --bail",
"test:deno:denokv": "npm run transpile && cross-env DEFAULT_STORAGE=denokv deno run --unstable-kv --unstable-broadcast-channel --unstable-byonm -A npm:mocha ./test/unit.test.ts --bail --timeout 150000",
"test:deno:denokv:loop": "npm run test:deno:denokv && npm run test:deno:denokv:loop",
"test:deno:memory": "npm run transpile && cross-env DEFAULT_STORAGE=memory deno run --unstable --allow-env --unstable-byonm --allow-read -A npm:mocha ./test/unit.test.ts --bail",
"test:deno:memory": "npm run transpile && cross-env DEFAULT_STORAGE=memory deno run --unstable --unstable-broadcast-channel --unstable-byonm -A npm:mocha ./test/unit.test.ts --bail",
"test:node:foundationdb": "npm run transpile && cross-env DEFAULT_STORAGE=foundationdb mocha --expose-gc --config ./config/.mocharc.cjs ./test_tmp/unit.test.js",
"test:node:mongodb": "npm run transpile && cross-env DEFAULT_STORAGE=mongodb mocha --expose-gc --config ./config/.mocharc.cjs ./test_tmp/unit.test.js",
"test:node:mongodb:loop": "npm run test:node:mongodb && npm run test:node:mongodb:loop",
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/storage-denokv/rx-storage-instance-denokv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export class RxStorageInstanceDenoKV<RxDocType> implements RxStorageInstance<
} catch (err: any) {
if (
err.message.includes('Error code 5:') ||
err.message.includes('Error code 517:')
err.message.includes('Error code 517:') ||
err.message.includes('database is locked')
) {
// retry
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/test-utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type TestConfig = {
storage: RxTestStorage;
};

export const isDeno = typeof window !== 'undefined' && 'Deno' in window;
export const isDeno = typeof Deno !== 'undefined' || (typeof window !== 'undefined' && 'Deno' in window);
export const isBun = typeof process !== 'undefined' && !!process.versions.bun;
export const isNode = !isDeno && !isBun && typeof window === 'undefined';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/test-utils/humans-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import clone from 'clone';
import * as schemas from './schemas.ts';
import * as schemaObjects from './schema-objects.ts';
import { getConfig } from './config.ts';
import assert from 'assert';
import assert from 'node:assert';

import {
createRxDatabase,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/test-utils/test-util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Func } from 'mocha';
import assert from 'assert';
import assert from 'node:assert';
import type { RxCollection } from '../../types';
import { requestIdlePromise } from '../utils/index.ts';
import type { RxReplicationState } from '../replication/index.ts';
Expand Down
2 changes: 1 addition & 1 deletion test/performance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
requestIdlePromise,
RxCollection
} from '../plugins/core/index.mjs';
import * as assert from 'assert';
import * as assert from 'node:assert';
import {
schemaObjects,
schemas,
Expand Down
2 changes: 1 addition & 1 deletion test/query-correctness-fuzzing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ensureNotFalsy,
normalizeMangoQuery
} from '../plugins/core/index.mjs';
import * as assert from 'assert';
import * as assert from 'node:assert';
import config from './unit/config.ts';
import {
randomOfArray
Expand Down
2 changes: 1 addition & 1 deletion test/replication-couchdb.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import config from './unit/config.ts';

import {
Expand Down
2 changes: 1 addition & 1 deletion test/replication-firestore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* this test checks the integration with firestore
* You need a running firebase backend
*/
import assert from 'assert';
import assert from 'node:assert';

import {
randomToken,
Expand Down
2 changes: 1 addition & 1 deletion test/replication-nats.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import config from './unit/config.ts';
import {
randomToken,
Expand Down
2 changes: 1 addition & 1 deletion test/typings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* this checks if typings work as expected
*/
import * as assert from 'assert';
import * as assert from 'node:assert';
import {
HumanCompositePrimaryDocType,
schemas
Expand Down
2 changes: 1 addition & 1 deletion test/unit/attachments-compression.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import config, { describeParallel } from './config.ts';
import AsyncTestUtil from 'async-test-util';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/attachments.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import config, { describeParallel } from './config.ts';
import AsyncTestUtil, { randomBoolean } from 'async-test-util';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/backup.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from 'node:path';
import * as fs from 'node:fs';

import assert from 'assert';
import assert from 'node:assert';
import { waitUntil } from 'async-test-util';
import config, { getRootPath } from './config.ts';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/bug-report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* - 'npm run test:node' so it runs in nodejs
* - 'npm run test:browser' so it runs in the browser
*/
import assert from 'assert';
import assert from 'node:assert';
import AsyncTestUtil from 'async-test-util';
import config from './config.ts';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/cache-replacement-policy.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import AsyncTestUtil, { wait, waitUntil } from 'async-test-util';
import { describeParallel } from './config.ts';
import {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/change-event-buffer.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';

import {
schemaObjects,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cleanup.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import { wait, waitUntil } from 'async-test-util';

import config, { describeParallel } from './config.ts';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/crdt.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import AsyncTestUtil, { clone } from 'async-test-util';

import { wrappedValidateAjvStorage } from '../../plugins/validate-ajv/index.mjs';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cross-instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* The tests for this behaviour are done here
*/

import assert from 'assert';
import assert from 'node:assert';
import AsyncTestUtil, { wait, waitUntil } from 'async-test-util';

import config, { describeParallel } from './config.ts';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/custom-index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import {
clone,
randomBoolean,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/database-lifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';

import config, { describeParallel } from './config.ts';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/encryption.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import config, { describeParallel } from './config.ts';
import AsyncTestUtil from 'async-test-util';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/event-reduce.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import { clone } from 'async-test-util';

import {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/full.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* this is run in a separate node-process via plugin.test.js
*/

import assert from 'assert';
import assert from 'node:assert';
import { assertThrows } from 'async-test-util';

/**
Expand Down
2 changes: 1 addition & 1 deletion test/unit/hooks.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import {
first
} from 'rxjs/operators';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/idle-queue.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import AsyncTestUtil from 'async-test-util';
import {
schemaObjects,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/import-export.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* this test is to the import/export behaviour
*/
import assert from 'assert';
import assert from 'node:assert';

import {
createRxDatabase,
Expand Down
6 changes: 3 additions & 3 deletions test/unit/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sourceMapSupport from 'source-map-support';
sourceMapSupport.install();
import '@babel/polyfill';
import config from './config.ts';
import assert from 'assert';
import assert from 'node:assert';
import {
clearNodeFolder
} from 'broadcast-channel';
Expand Down Expand Up @@ -68,11 +68,11 @@ describe('init.test.ts', () => {
});
it('start test servers', async () => {
if (isNode) {
console.log('START TEST SERVERS');
console.log('START TEST SERVERS...NODE');
const { startTestServers } = await import('' + '../helper/test-servers.js' + '');
startTestServers();
} else if (isDeno) {
console.log('START TEST SERVERS');
console.log('START TEST SERVERS...DENO');
const { startTestServers } = await import('' + '../helper/test-servers.ts' + '');
startTestServers();
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/instance-of-check.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';

import { describeParallel } from './config.ts';
import {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/internal-indexes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import { describeParallel } from './config.ts';
import {
schemaObjects,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/key-compression.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* this test is for the keycompression-capabilities of rxdb
*/
import assert from 'assert';
import assert from 'node:assert';
import config, { describeParallel } from './config.ts';


Expand Down
2 changes: 1 addition & 1 deletion test/unit/last.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import { waitUntil } from 'async-test-util';
import {
dbCount,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/leader-election.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import AsyncTestUtil from 'async-test-util';
import config, { describeParallel } from './config.ts';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/local-documents.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import AsyncTestUtil, { wait, waitUntil, randomString } from 'async-test-util';

import {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/migration-schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import config, { describeParallel } from './config.ts';
import AsyncTestUtil, { waitUntil } from 'async-test-util';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/migration-storage.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import {
randomToken,
createRxDatabase,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/orm.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import AsyncTestUtil from 'async-test-util';

import config, { describeParallel } from './config.ts';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @nodeOnly
*/

import assert from 'assert';
import assert from 'node:assert';
import {
addRxPlugin,
randomToken,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/population.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import config, { describeParallel } from './config.ts';

import {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/query-builder.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';

import type {
MangoQuery
Expand Down
2 changes: 1 addition & 1 deletion test/unit/query-planner.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import {
clone
} from 'async-test-util';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/reactive-collection.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import config, { describeParallel } from './config.ts';

import {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/reactive-document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* this tests the reactive behaviour of RxDocument
*/

import assert from 'assert';
import assert from 'node:assert';
import AsyncTestUtil from 'async-test-util';

import config, { describeParallel } from './config.ts';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/reactive-query.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import clone from 'clone';
import config, { describeParallel } from './config.ts';

Expand Down
2 changes: 1 addition & 1 deletion test/unit/reactivity.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import { describeParallel } from './config.ts';


Expand Down
2 changes: 1 addition & 1 deletion test/unit/replication-graphql.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import {
assertThrows,
clone,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/replication-protocol.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';

import config, { describeParallel } from './config.ts';
import {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/replication-webrtc.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import config from './config.ts';
import {
randomToken,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/replication-websocket.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import {
wait, waitUntil
} from 'async-test-util';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/replication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* we do that inside of the GraphQL replication plugin.
*/

import assert from 'assert';
import assert from 'node:assert';
import {
clone,
wait,
Expand Down
Loading

0 comments on commit 8bec337

Please sign in to comment.