mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-24 01:53:20 +00:00
revert deno test
This commit is contained in:
9 files changed
+11
-20
No files matched your search
@@ -2,7 +2,7 @@ import * as fs from "fs/promises";
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import type { UXDataWriteOptions } from "@lib/common/types";
|
import type { UXDataWriteOptions } from "@lib/common/types";
|
||||||
import type { IVaultAdapter } from "@lib/serviceModules/adapters";
|
import type { IVaultAdapter } from "@lib/serviceModules/adapters";
|
||||||
import type { NodeFile, NodeFolder, NodeStat } from "./NodeTypes";
|
import type { NodeFile, NodeFolder } from "./NodeTypes";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vault adapter implementation for Node.js
|
* Vault adapter implementation for Node.js
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { applyRemoteSyncSettings, initSettingsFile } from "./helpers/settings.ts
|
|||||||
import { assertFilesEqual, runCliOrFail } from "./helpers/cli.ts";
|
import { assertFilesEqual, runCliOrFail } from "./helpers/cli.ts";
|
||||||
import { startCouchdb, stopCouchdb } from "./helpers/docker.ts";
|
import { startCouchdb, stopCouchdb } from "./helpers/docker.ts";
|
||||||
import { createDeterministicDataset, type DatasetEntry } from "./helpers/dataset.ts";
|
import { createDeterministicDataset, type DatasetEntry } from "./helpers/dataset.ts";
|
||||||
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
|
|
||||||
|
|
||||||
type BenchmarkConfig = {
|
type BenchmarkConfig = {
|
||||||
couchdbBackendUri: string;
|
couchdbBackendUri: string;
|
||||||
@@ -138,7 +137,7 @@ function startCouchdbProxy(options: { backendUri: string; proxyUri: string; requ
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
async (request) => {
|
async (request) => {
|
||||||
await new Promise((resolve) => compatGlobal.setTimeout(resolve, halfDelayMs));
|
await new Promise((resolve) => setTimeout(resolve, halfDelayMs));
|
||||||
|
|
||||||
const targetUrl = new URL(request.url);
|
const targetUrl = new URL(request.url);
|
||||||
targetUrl.protocol = backend.protocol;
|
targetUrl.protocol = backend.protocol;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { CLI_DIR, TEE_ENABLED, formatTeeCommand, createLineTeeWriter } from "./cli.ts";
|
import { CLI_DIR, TEE_ENABLED, formatTeeCommand, createLineTeeWriter } from "./cli.ts";
|
||||||
import { join } from "@std/path";
|
import { join } from "@std/path";
|
||||||
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
|
|
||||||
|
|
||||||
const CLI_DIST = join(CLI_DIR, "dist", "index.cjs");
|
const CLI_DIST = join(CLI_DIR, "dist", "index.cjs");
|
||||||
const VERBOSE_ENABLED = Deno.env.get("LIVESYNC_CLI_VERBOSE") === "1";
|
const VERBOSE_ENABLED = Deno.env.get("LIVESYNC_CLI_VERBOSE") === "1";
|
||||||
@@ -79,7 +78,7 @@ export class BackgroundCliProcess {
|
|||||||
const status = await Promise.race([
|
const status = await Promise.race([
|
||||||
this.child.status.then((s) => ({ type: "status" as const, status: s })),
|
this.child.status.then((s) => ({ type: "status" as const, status: s })),
|
||||||
new Promise<{ type: "tick" }>((resolve) =>
|
new Promise<{ type: "tick" }>((resolve) =>
|
||||||
compatGlobal.setTimeout(() => resolve({ type: "tick" }), 100)
|
setTimeout(() => resolve({ type: "tick" }), 100)
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
if (status.type === "status") {
|
if (status.type === "status") {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { join } from "@std/path";
|
import { join } from "@std/path";
|
||||||
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Path resolution
|
// Path resolution
|
||||||
@@ -26,7 +25,7 @@ const VERBOSE_ENABLED = Deno.env.get("LIVESYNC_CLI_VERBOSE") === "1";
|
|||||||
const DEBUG_ENABLED = Deno.env.get("LIVESYNC_CLI_DEBUG") === "1";
|
const DEBUG_ENABLED = Deno.env.get("LIVESYNC_CLI_DEBUG") === "1";
|
||||||
|
|
||||||
function sleep(ms: number): Promise<void> {
|
function sleep(ms: number): Promise<void> {
|
||||||
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
function concatChunks(chunks: Uint8Array[]): Uint8Array {
|
function concatChunks(chunks: Uint8Array[]): Uint8Array {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Docker service management for tests.
|
* Docker service management for tests.
|
||||||
*
|
*
|
||||||
@@ -258,7 +256,7 @@ function untrackContainer(container: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sleep(ms: number): Promise<void> {
|
function sleep(ms: number): Promise<void> {
|
||||||
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitForCouchdbStable(hostname: string, user: string, password: string): Promise<void> {
|
async function waitForCouchdbStable(hostname: string, user: string, password: string): Promise<void> {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
|
|
||||||
|
|
||||||
type WaitForPortOptions = {
|
type WaitForPortOptions = {
|
||||||
timeoutMs?: number;
|
timeoutMs?: number;
|
||||||
intervalMs?: number;
|
intervalMs?: number;
|
||||||
@@ -7,7 +5,7 @@ type WaitForPortOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function sleep(ms: number): Promise<void> {
|
function sleep(ms: number): Promise<void> {
|
||||||
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function connectWithTimeout(hostname: string, port: number, timeoutMs: number): Promise<void> {
|
async function connectWithTimeout(hostname: string, port: number, timeoutMs: number): Promise<void> {
|
||||||
@@ -15,13 +13,13 @@ async function connectWithTimeout(hostname: string, port: number, timeoutMs: num
|
|||||||
try {
|
try {
|
||||||
const connPromise = Deno.connect({ hostname, port });
|
const connPromise = Deno.connect({ hostname, port });
|
||||||
const timeoutPromise = new Promise<never>((_, reject) => {
|
const timeoutPromise = new Promise<never>((_, reject) => {
|
||||||
timer = compatGlobal.setTimeout(() => reject(new Error(`connect timeout after ${timeoutMs}ms`)), timeoutMs);
|
timer = setTimeout(() => reject(new Error(`connect timeout after ${timeoutMs}ms`)), timeoutMs);
|
||||||
});
|
});
|
||||||
const conn = await Promise.race([connPromise, timeoutPromise]);
|
const conn = await Promise.race([connPromise, timeoutPromise]);
|
||||||
conn.close();
|
conn.close();
|
||||||
} finally {
|
} finally {
|
||||||
if (timer !== undefined) {
|
if (timer !== undefined) {
|
||||||
compatGlobal.clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { runCli } from "./cli.ts";
|
import { runCli } from "./cli.ts";
|
||||||
import { isLocalP2pRelay, startP2pRelay, stopP2pRelay, startCoturn, stopCoturn } from "./docker.ts";
|
import { isLocalP2pRelay, startP2pRelay, stopP2pRelay, startCoturn, stopCoturn } from "./docker.ts";
|
||||||
import { waitForPort } from "./net.ts";
|
import { waitForPort } from "./net.ts";
|
||||||
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
|
|
||||||
|
|
||||||
export type PeerEntry = {
|
export type PeerEntry = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -9,7 +8,7 @@ export type PeerEntry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function sleep(ms: number): Promise<void> {
|
function sleep(ms: number): Promise<void> {
|
||||||
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseRelayEndpoint(relay: string): { hostname: string; port: number } {
|
function parseRelayEndpoint(relay: string): { hostname: string; port: number } {
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ Deno.test("CLI file operations: push / cat / ls / info / rm / resolve / cat-rev
|
|||||||
assertEquals(data.path, REMOTE_PATH, "info .path mismatch");
|
assertEquals(data.path, REMOTE_PATH, "info .path mismatch");
|
||||||
assertEquals(data.filename, REMOTE_PATH.split("/").at(-1), "info .filename mismatch");
|
assertEquals(data.filename, REMOTE_PATH.split("/").at(-1), "info .filename mismatch");
|
||||||
assert(typeof data.size === "number" && data.size >= 0, `info .size invalid: ${data.size}`);
|
assert(typeof data.size === "number" && data.size >= 0, `info .size invalid: ${data.size}`);
|
||||||
assert(typeof data.chunks === "number" && (data.chunks as number) >= 1, `info .chunks invalid: ${data.chunks}`);
|
assert(typeof data.chunks === "number" && (data.chunks) >= 1, `info .chunks invalid: ${data.chunks}`);
|
||||||
assertEquals(data.conflicts, "N/A", "info .conflicts should be N/A");
|
assertEquals(data.conflicts, "N/A", "info .conflicts should be N/A");
|
||||||
console.log("[PASS] info output format matched");
|
console.log("[PASS] info output format matched");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import { TempDir } from "./helpers/temp.ts";
|
|||||||
import { runCliOrFail, jsonFieldIsNa } from "./helpers/cli.ts";
|
import { runCliOrFail, jsonFieldIsNa } from "./helpers/cli.ts";
|
||||||
import { applyCouchdbSettings, initSettingsFile } from "./helpers/settings.ts";
|
import { applyCouchdbSettings, initSettingsFile } from "./helpers/settings.ts";
|
||||||
import { startCouchdb, stopCouchdb } from "./helpers/docker.ts";
|
import { startCouchdb, stopCouchdb } from "./helpers/docker.ts";
|
||||||
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Load configuration
|
// Load configuration
|
||||||
@@ -110,7 +109,7 @@ async function runSuite(
|
|||||||
config: { uri: string; user: string; password: string },
|
config: { uri: string; user: string; password: string },
|
||||||
dbname: string
|
dbname: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const sleep = (ms: number) => new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
|
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
const runWithRetry = async <T>(label: string, fn: () => Promise<T>, retries = SYNC_RETRY): Promise<T> => {
|
const runWithRetry = async <T>(label: string, fn: () => Promise<T>, retries = SYNC_RETRY): Promise<T> => {
|
||||||
let lastErr: unknown;
|
let lastErr: unknown;
|
||||||
for (let i = 0; i <= retries; i++) {
|
for (let i = 0; i <= retries; i++) {
|
||||||
|
|||||||
Reference in new issue
Block a user