From f21ac7bb4280856c1d6395cd3876fd1fdfeca4f3 Mon Sep 17 00:00:00 2001 From: Noah Schatz Date: Sun, 29 Nov 2026 23:44:44 -0500 Subject: [PATCH 1/6] fix(nodes): wait for the id another start is writing Two starts at once with no node id: the second read the id file between the first one's exclusive create and its write, found it empty, and ran under an unsaved id of its own. An empty file is now read again, for up to a second, until the id is in. --- .changeset/node-id-race.md | 5 +++++ README.md | 12 ++++++++++++ src/engine/nodes.ts | 29 ++++++++++++++++++++++++++--- test/nodes.test.ts | 14 ++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 .changeset/node-id-race.md diff --git a/.changeset/node-id-race.md b/.changeset/node-id-race.md new file mode 100644 index 00000000..e46ae19c --- /dev/null +++ b/.changeset/node-id-race.md @@ -0,0 +1,5 @@ +--- +"@cosyte/pathways": patch +--- + +Two engines started at once in one project with no `node.id` now agree on one node id. The second used to read the id file while the first had made it and not yet written it, and so ran under an id of its own that was never saved. diff --git a/README.md b/README.md index 5f0ec73b..41d086c8 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ version is 0.0.x, and a release may still change a key or an API, which its chan - [Quickstart](#quickstart) - [Why this exists](#why-this-exists) - [What the latest release ships](#what-the-latest-release-ships) +- [In the next release](#in-the-next-release) - [Status](#status) - [Build from source](#build-from-source) - [Layout](#layout) @@ -234,6 +235,17 @@ What follows is in 0.0.7, the version on npm: --- +## In the next release + +These are on `main` and land in the next release: + +- **Two engines started at once agree on a node id.** When two engines start together in a project + that sets no `node.id`, the second now takes the id the first writes, where it used to run under + one of its own that was never saved. + + +--- + ## Status Early, and released: 0.0.7 is on npm. Each release is published with provenance from this diff --git a/src/engine/nodes.ts b/src/engine/nodes.ts index 2ba90c24..7f498e51 100644 --- a/src/engine/nodes.ts +++ b/src/engine/nodes.ts @@ -62,8 +62,9 @@ export async function resolveNodeId( return { id, from: "kept" }; } catch (error) { const code = (error as NodeJS.ErrnoException).code; - // Another start wrote it first: take that one, so both name the same node. - const raced = code === "EEXIST" ? await readKept(file) : undefined; + // Another start made it first: take its id, so both name the same node. After any other + // failure there is no file to read, and the read finds none. + const raced = await readWritten(file); if (raced !== undefined) return { id: raced, from: "kept" }; return { id, from: "unsaved", code }; } @@ -71,11 +72,33 @@ export async function resolveNodeId( /** The id kept in `file`, or undefined when there is none or it is not a node id. */ async function readKept(file: string): Promise { - const text = await readFile(file, "utf8").catch(() => undefined); + return keptId(await readFile(file, "utf8").catch(() => undefined)); +} + +/** The node id in a kept file's text, or undefined when the text holds none. */ +function keptId(text: string | undefined): string | undefined { const id = text?.trim(); return id !== undefined && NODE_ID.test(id) ? id : undefined; } +/** How many times, and how far apart, a start reads a node id file another start has made empty. */ +const WRITTEN_READS = 40; +const WRITTEN_READ_GAP_MS = 25; + +/** + * The id another start writes into `file`. Its exclusive create makes the file empty and its write + * fills it a moment later, so an empty file is read again, for up to a second, until the id is in. + * A file that stays empty, or holds no node id, gives undefined. + */ +async function readWritten(file: string): Promise { + for (let read = 1; ; read++) { + const text = await readFile(file, "utf8").catch(() => undefined); + // Stryker disable next-line ConditionalExpression: text read again later gives the same id + if (text !== "" || read === WRITTEN_READS) return keptId(text); + await sleep(WRITTEN_READ_GAP_MS); + } +} + /** * Whether the process `pid` runs on this host. A signal 0 checks without sending one; `EPERM` means * it runs under another user. diff --git a/test/nodes.test.ts b/test/nodes.test.ts index d03ef945..1cff405b 100644 --- a/test/nodes.test.ts +++ b/test/nodes.test.ts @@ -6,6 +6,7 @@ // test/nodes-store.test.ts. import { readFile, stat, writeFile } from "node:fs/promises"; import { join } from "node:path"; +import { setTimeout as sleep } from "node:timers/promises"; import { afterEach, describe, expect, it, vi } from "vitest"; @@ -412,6 +413,19 @@ describe("A node id", () => { expect(await resolveNodeId(root, undefined)).toEqual(first); }); + it("is the other start's id when that start has made the file and not yet written it", async () => { + // The moment between the other start's exclusive create and its write: the file is there and + // empty. The id written into it next is the one this start takes. + const root = await makeProject({ [NODE_ID_FILE]: "" }); + const writing = sleep(30).then(() => writeFile(join(root, NODE_ID_FILE), "engine-b\n")); + const [resolved] = await Promise.all([resolveNodeId(root, undefined), writing]); + expect(resolved).toEqual({ id: "engine-b", from: "kept" }); + // A file left empty, by a start that stopped before its write, is waited on and then left. + const left = await makeProject({ [NODE_ID_FILE]: "" }); + expect(await resolveNodeId(left, undefined)).toMatchObject({ from: "unsaved", code: "EEXIST" }); + expect(await readFile(join(left, NODE_ID_FILE), "utf8")).toBe(""); + }); + it("is one for this process alone, with the code, when the state folder cannot keep it", async () => { // .pathways is a file: there is no folder to write in. const blocked = await makeProject({ ".pathways": "" }); From b7a56cf2f777bff9a325e3b345d22ce7dafbc96e Mon Sep 17 00:00:00 2001 From: Noah Schatz Date: Sun, 29 Nov 2026 23:48:36 -0500 Subject: [PATCH 2/6] test: move the shared test helpers to test/_helpers The twenty helper modules (fakes, stores held in memory, project and network helpers) sat beside the test files. They now live in test/_helpers/, so test/ holds test files, and every import, module path and comment that names one follows it. --- eslint.config.js | 9 +++++---- scripts/bench.ts | 2 +- scripts/phi-allow-list.txt | 2 +- src/env.ts | 2 +- test/{ => _helpers}/databases.ts | 10 +++++----- test/{ => _helpers}/docs-helpers.ts | 2 +- test/{ => _helpers}/env-access-cases.ts | 0 test/{ => _helpers}/env-types.ts | 13 +++++++------ test/{ => _helpers}/extension-helpers.ts | 2 +- test/{ => _helpers}/fake-location.ts | 2 +- test/{ => _helpers}/fake-object-store.ts | 2 +- test/{ => _helpers}/fake-ssh2.ts | 0 test/{ => _helpers}/helpers.ts | 0 test/{ => _helpers}/lease-memory-store.ts | 14 +++++++------- test/{ => _helpers}/memory-store.ts | 2 +- test/{ => _helpers}/mllp-helpers.ts | 0 test/{ => _helpers}/net-helpers.ts | 0 test/{ => _helpers}/node-memory-store.ts | 12 ++++++------ test/{ => _helpers}/openmetrics.ts | 0 test/{ => _helpers}/receive-keys.ts | 2 +- test/{ => _helpers}/secret-vault.ts | 8 ++++++-- test/{ => _helpers}/smtp-peer.ts | 0 test/{ => _helpers}/ssh-keys.ts | 0 test/{ => _helpers}/sshd.ts | 0 test/batch-crash.test.ts | 4 ++-- test/batch-engine.test.ts | 2 +- test/batch.test.ts | 11 ++++++++--- test/bulk-replay.test.ts | 4 ++-- test/channel-control.test.ts | 4 ++-- test/channel-routing.test.ts | 4 ++-- test/channel-scripts.test.ts | 4 ++-- test/channel-worker.test.ts | 2 +- test/claims-and-links.test.ts | 13 ++++++++++--- test/cli-edges.test.ts | 4 ++-- test/cli-lease.test.ts | 8 ++++---- test/cli-migrate.test.ts | 4 ++-- test/cli-nodes.test.ts | 6 +++--- test/cli-operator.test.ts | 4 ++-- test/cli-secrets-check.test.ts | 8 ++++---- test/cli-unexpected.test.ts | 2 +- test/cli-validate.test.ts | 2 +- test/cli.test.ts | 4 ++-- test/config-edges.test.ts | 2 +- test/config-env.test.ts | 2 +- test/config-json-schema.test.ts | 2 +- test/config.test.ts | 2 +- test/connector-runtime.test.ts | 4 ++-- test/content-drop.test.ts | 6 +++--- test/content-none.test.ts | 13 ++++++++++--- test/control.test.ts | 2 +- test/cron-load-failure.test.ts | 2 +- test/csv-format.test.ts | 4 ++-- test/delivery-queued-at.test.ts | 4 ++-- test/destination-identity.test.ts | 12 +++++++++--- test/destination-transform.test.ts | 12 +++++++++--- test/dialects.test.ts | 4 ++-- test/docs-content.test.ts | 6 +++--- test/drain-process.test.ts | 4 ++-- test/drain.test.ts | 6 +++--- test/dry-run.test.ts | 6 +++--- test/encrypted-store.test.ts | 11 +++++++++-- test/encryption-cli.test.ts | 4 ++-- test/encryption.test.ts | 2 +- test/endpoint.test.ts | 7 ++++++- test/engine-edges.test.ts | 4 ++-- test/engine-http.test.ts | 4 ++-- test/engine-memory.test.ts | 2 +- test/engine-stop.test.ts | 10 ++++++++-- test/engine.test.ts | 4 ++-- test/env-access.test.ts | 8 ++++---- test/env-example.test.ts | 6 +++--- test/examples.test.ts | 8 ++++---- test/extension-encryption.test.ts | 6 +++--- test/extension-types.test.ts | 2 +- test/extensions.test.ts | 10 +++++----- test/fault-points.test.ts | 4 ++-- test/file-location.test.ts | 4 ++-- test/file-source-options.test.ts | 2 +- test/file-source-race.test.ts | 2 +- test/file-source-sync.test.ts | 2 +- test/file-source.test.ts | 8 +++++++- test/format-equivalence.test.ts | 2 +- test/hl7v2-charset.test.ts | 4 ++-- test/hooks.test.ts | 6 +++--- test/http-destination-options.test.ts | 6 +++--- test/http-destination.test.ts | 4 ++-- test/http-retry-engine.test.ts | 6 +++--- test/http-source-options.test.ts | 4 ++-- test/http-source.test.ts | 9 +++++++-- test/http-xml-ack.test.ts | 4 ++-- test/init.test.ts | 2 +- test/lease-processes.test.ts | 4 ++-- test/lease-store.test.ts | 6 +++--- test/meta-index.test.ts | 6 +++--- test/metrics-engine.test.ts | 15 +++++++++++---- test/metrics.test.ts | 16 +++++++++++----- test/mllp-destination.test.ts | 13 ++++++++++--- test/mllp-dial-out.test.ts | 6 +++--- test/mllp-engine.test.ts | 6 +++--- test/mllp-options.test.ts | 6 +++--- test/mllp-source.test.ts | 6 +++--- test/net-helpers.test.ts | 2 +- test/nodes-processes.test.ts | 4 ++-- test/nodes-store.test.ts | 12 +++++++++--- test/nodes.test.ts | 2 +- test/object-store-config.test.ts | 2 +- test/object-store.test.ts | 10 +++++----- test/one-message.test.ts | 4 ++-- test/operator-edges.test.ts | 4 ++-- test/operator.test.ts | 4 ++-- test/output-equivalence.test.ts | 2 +- test/ownership.test.ts | 4 ++-- test/poll-schedule.test.ts | 2 +- test/probe-codeless.test.ts | 2 +- test/probes.test.ts | 8 ++++---- test/receive-race.test.ts | 6 +++--- test/requeue-race.test.ts | 4 ++-- test/retention-archive.test.ts | 10 ++++++++-- test/retry-settings.test.ts | 11 ++++++++--- test/run-tests.test.ts | 2 +- test/safe-to-log-docs.test.ts | 4 ++-- test/schema-steps.test.ts | 4 ++-- test/schema-versions.test.ts | 4 ++-- test/scripts/phi-scan.test.ts | 2 +- test/secrets-property.test.ts | 8 ++++---- test/secrets.test.ts | 10 +++++----- test/send-marker.test.ts | 6 +++--- test/settled.test.ts | 4 ++-- test/sftp-config.test.ts | 4 ++-- test/sftp-crash.test.ts | 8 ++++---- test/sftp-server.test.ts | 8 ++++---- test/sftp.test.ts | 4 ++-- test/smtp-config.test.ts | 8 ++++---- test/smtp.test.ts | 8 ++++---- test/sqlite-statements.test.ts | 2 +- test/ssh-keys.test.ts | 11 ++++++----- test/store-edges.test.ts | 2 +- test/store-operator.test.ts | 4 ++-- test/store-servers.test.ts | 4 ++-- test/store-sql-mode.test.ts | 2 +- test/store.test.ts | 4 ++-- test/tcp-config.test.ts | 4 ++-- test/tcp-destination.test.ts | 4 ++-- test/tcp-source.test.ts | 4 ++-- test/transform-context.test.ts | 9 +++++++-- test/transform-types.test.ts | 2 +- test/verify.test.ts | 9 ++++++++- test/webhook.test.ts | 13 +++++++++---- test/worker-entry.test.ts | 9 ++++++++- test/worker-memory.test.ts | 2 +- test/xml-format.test.ts | 4 ++-- 151 files changed, 451 insertions(+), 323 deletions(-) rename test/{ => _helpers}/databases.ts (96%) rename test/{ => _helpers}/docs-helpers.ts (99%) rename test/{ => _helpers}/env-access-cases.ts (100%) rename test/{ => _helpers}/env-types.ts (92%) rename test/{ => _helpers}/extension-helpers.ts (98%) rename test/{ => _helpers}/fake-location.ts (99%) rename test/{ => _helpers}/fake-object-store.ts (99%) rename test/{ => _helpers}/fake-ssh2.ts (100%) rename test/{ => _helpers}/helpers.ts (100%) rename test/{ => _helpers}/lease-memory-store.ts (89%) rename test/{ => _helpers}/memory-store.ts (99%) rename test/{ => _helpers}/mllp-helpers.ts (100%) rename test/{ => _helpers}/net-helpers.ts (100%) rename test/{ => _helpers}/node-memory-store.ts (89%) rename test/{ => _helpers}/openmetrics.ts (100%) rename test/{ => _helpers}/receive-keys.ts (94%) rename test/{ => _helpers}/secret-vault.ts (94%) rename test/{ => _helpers}/smtp-peer.ts (100%) rename test/{ => _helpers}/ssh-keys.ts (100%) rename test/{ => _helpers}/sshd.ts (100%) diff --git a/eslint.config.js b/eslint.config.js index d1f05b95..10e5350b 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -5,10 +5,11 @@ import cosyte from "@cosyte/eslint-config"; // compares both ways with the .env.example files, and reads a name configuration gives through one // function. Everywhere else in src/ these rules refuse the listed ways to reach the environment // around it, and test/env-access.test.ts lints each listed way against them. Any other route is -// caught by review, not by a check. An environment object handed along (`io.env`, a context's `env`) -// may be passed on, but not read, spread or listed outside src/env.ts. The types hold most of this -// too (src/env.ts makes Env opaque, and test/env-types.ts checks it); these rules also cover -// `process` itself, which the types do not, and a fixed name written where configuration gives one. +// caught by review, not by a check. An environment object handed along (`io.env`, a context's +// `env`) may be passed on, but not read, spread or listed outside src/env.ts. The types hold most +// of this too (src/env.ts makes Env opaque, and test/_helpers/env-types.ts checks it); these rules +// also cover `process` itself, which the types do not, and a fixed name written where configuration +// gives one. const ENV_ONLY_IN_ENV_TS = "Read the environment through src/env.ts (engineVariable or configuredVariable)."; diff --git a/scripts/bench.ts b/scripts/bench.ts index 3dddc001..645f245b 100644 --- a/scripts/bench.ts +++ b/scripts/bench.ts @@ -26,7 +26,7 @@ import { EncryptedStore, UnencryptedStore } from "../src/encryption/encrypted-st import { decodeKey, generateKey, LocalKeyProvider } from "../src/encryption/keys.js"; import { Engine } from "../src/engine/engine.js"; import { Store } from "../src/storage/store.js"; -import { closeAdmins, dropDatabases, freshDatabase, URL_ENV } from "../test/databases.js"; +import { closeAdmins, dropDatabases, freshDatabase, URL_ENV } from "../test/_helpers/databases.js"; const count = Number(process.argv[2] ?? 2000); const kind = (process.argv[3] ?? "sqlite") as StorageKind; diff --git a/scripts/phi-allow-list.txt b/scripts/phi-allow-list.txt index 148e684b..313de94c 100644 --- a/scripts/phi-allow-list.txt +++ b/scripts/phi-allow-list.txt @@ -49,7 +49,7 @@ EMAILDOMAIN cosyte.com EMAILDOMAIN openssh.com # --- Synthetic person-name tokens --- -# The test patient every fixture in this repository uses: test/helpers.ts (HL7 +# The test patient every fixture in this repository uses: test/_helpers/helpers.ts (HL7 # v2, FHIR, X12 and C-CDA) and scripts/bench.ts. Obviously not a person. NAME TESTPATIENT NAME ALPHA diff --git a/src/env.ts b/src/env.ts index 51d23871..6c93a7c4 100644 --- a/src/env.ts +++ b/src/env.ts @@ -4,7 +4,7 @@ // ENGINE_VARIABLES; and a secret's variable (configuredVariable, a SecretSource's `env`, readEnv, // the env provider's request) is a VariableName: a listed name, or a ConfiguredVariableName, which // configuredName makes where a name comes from configuration (test/env-access.test.ts lists those -// calls). test/env-types.ts holds the type checker to each case. And the lint rule in +// calls). test/_helpers/env-types.ts holds the type checker to each case. And the lint rule in // eslint.config.js refuses `process.env` and the other listed ways to the process's own environment, // processEnv() anywhere but bound to an `env`, and a literal where configuration gives a name. Any // other route is caught by review, not by a check. test/env-example.test.ts compares the three diff --git a/test/databases.ts b/test/_helpers/databases.ts similarity index 96% rename from test/databases.ts rename to test/_helpers/databases.ts index f864ce45..a52ff65f 100644 --- a/test/databases.ts +++ b/test/_helpers/databases.ts @@ -2,11 +2,11 @@ import { randomBytes } from "node:crypto"; import { Kysely, sql } from "kysely"; -import type { DatabaseStorage, ServerStorage, StorageKind } from "../src/config/schema.js"; -import type { Env } from "../src/connectors/endpoint.js"; -import { dialectFor } from "../src/storage/dialects.js"; -import { ENGINE_LEASE, Store, type StoreOptions } from "../src/storage/store.js"; -import { configuredName } from "../src/env.js"; +import type { DatabaseStorage, ServerStorage, StorageKind } from "../../src/config/schema.js"; +import type { Env } from "../../src/connectors/endpoint.js"; +import { dialectFor } from "../../src/storage/dialects.js"; +import { ENGINE_LEASE, Store, type StoreOptions } from "../../src/storage/store.js"; +import { configuredName } from "../../src/env.js"; /** * One database the storage, engine and operator suites run on. SQLite always runs; each server runs diff --git a/test/docs-helpers.ts b/test/_helpers/docs-helpers.ts similarity index 99% rename from test/docs-helpers.ts rename to test/_helpers/docs-helpers.ts index c7351e80..6c1dcc80 100644 --- a/test/docs-helpers.ts +++ b/test/_helpers/docs-helpers.ts @@ -5,7 +5,7 @@ import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; /** The package root, the docs folder, and the built command the pages run. */ -export const ROOT = join(import.meta.dirname, ".."); +export const ROOT = join(import.meta.dirname, "..", ".."); export const DOCS_DIR = join(ROOT, "docs-content"); export const BIN = join(ROOT, "dist", "bin", "pathways.mjs"); diff --git a/test/env-access-cases.ts b/test/_helpers/env-access-cases.ts similarity index 100% rename from test/env-access-cases.ts rename to test/_helpers/env-access-cases.ts diff --git a/test/env-types.ts b/test/_helpers/env-types.ts similarity index 92% rename from test/env-types.ts rename to test/_helpers/env-types.ts index 9023a208..725990cf 100644 --- a/test/env-types.ts +++ b/test/_helpers/env-types.ts @@ -3,11 +3,12 @@ * run. Each line under a `@ts-expect-error` is a way to read a variable around engineVariable and * ENGINE_VARIABLES; if the type checker ever lets one compile, the directive is unused and the * typecheck fails. The lint rule in eslint.config.js refuses the same code by its syntax, and - * test/env-access-cases.ts holds those cases; here the types refuse it whatever it is called. + * test/_helpers/env-access-cases.ts holds those cases; here the types refuse it whatever it is + * called. */ -import type { SecretSource } from "../src/config/schema.js"; -import { readEnv } from "../src/connectors/endpoint.js"; +import type { SecretSource } from "../../src/config/schema.js"; +import { readEnv } from "../../src/connectors/endpoint.js"; import { configuredName, configuredVariable, @@ -15,9 +16,9 @@ import { engineVariable, type Env, processEnv, -} from "../src/env.js"; -import { readEnvSecret } from "../src/secrets/provider.js"; -import { secretsOf } from "../src/secrets/resolve.js"; +} from "../../src/env.js"; +import { readEnvSecret } from "../../src/secrets/provider.js"; +import { secretsOf } from "../../src/secrets/resolve.js"; /** The reviewers' cases, each refused by the type checker. */ export function refused(env: Env, io: { readonly env: Env }): readonly unknown[] { diff --git a/test/extension-helpers.ts b/test/_helpers/extension-helpers.ts similarity index 98% rename from test/extension-helpers.ts rename to test/_helpers/extension-helpers.ts index 0b448892..1b62e94f 100644 --- a/test/extension-helpers.ts +++ b/test/_helpers/extension-helpers.ts @@ -169,7 +169,7 @@ export default (request: Request): Uint8Array => { export const HANGING_ACK = "export default (): Promise => new Promise(() => undefined);\n"; -/** The in-memory store's module, test/memory-store.ts, for `storage: { module }`. */ +/** The in-memory store's module, test/_helpers/memory-store.ts, for `storage: { module }`. */ export const MEMORY_STORE_FILE = fileURLToPath(new URL("./memory-store.ts", import.meta.url)); /** Waits until `check` passes, or fails after `timeoutMs`. */ diff --git a/test/fake-location.ts b/test/_helpers/fake-location.ts similarity index 99% rename from test/fake-location.ts rename to test/_helpers/fake-location.ts index 613734a5..fbf928db 100644 --- a/test/fake-location.ts +++ b/test/_helpers/fake-location.ts @@ -6,7 +6,7 @@ import type { FileStat, Location, OpenFile, -} from "../src/connectors/file-system.js"; +} from "../../src/connectors/file-system.js"; /** One file in a {@link FakeLocation}: its bytes, its modification time and its id. */ interface FakeFile { diff --git a/test/fake-object-store.ts b/test/_helpers/fake-object-store.ts similarity index 99% rename from test/fake-object-store.ts rename to test/_helpers/fake-object-store.ts index 8090248a..b4fc6d5e 100644 --- a/test/fake-object-store.ts +++ b/test/_helpers/fake-object-store.ts @@ -4,7 +4,7 @@ import { type ObjectPage, type ObjectStore, objectFailure, -} from "../src/connectors/object-store.js"; +} from "../../src/connectors/object-store.js"; /** One object held by the {@link FakeObjectStore}. */ interface Held { diff --git a/test/fake-ssh2.ts b/test/_helpers/fake-ssh2.ts similarity index 100% rename from test/fake-ssh2.ts rename to test/_helpers/fake-ssh2.ts diff --git a/test/helpers.ts b/test/_helpers/helpers.ts similarity index 100% rename from test/helpers.ts rename to test/_helpers/helpers.ts diff --git a/test/lease-memory-store.ts b/test/_helpers/lease-memory-store.ts similarity index 89% rename from test/lease-memory-store.ts rename to test/_helpers/lease-memory-store.ts index 6f57030d..9db27fdf 100644 --- a/test/lease-memory-store.ts +++ b/test/_helpers/lease-memory-store.ts @@ -1,9 +1,9 @@ -// The in-memory store of test/memory-store.ts with the lease methods a custom store may add, written -// as a user would add them: a lease row per name, its expiry judged by one clock (here this -// process's, standing in for a database's), and each fenced write refused with LeaseLostError when -// the epoch it carries is no longer the lease's. Every store this module makes shares the lease rows, -// as engines on one database share its table, so two `pathways start` runs in one test process -// contend for one lease. +// The in-memory store of test/_helpers/memory-store.ts with the lease methods a custom store may +// add, written as a user would add them: a lease row per name, its expiry judged by one clock (here +// this process's, standing in for a database's), and each fenced write refused with LeaseLostError +// when the epoch it carries is no longer the lease's. Every store this module makes shares the +// lease rows, as engines on one database share its table, so two `pathways start` runs in one test +// process contend for one lease. import { LeaseLostError, type LeaseClaim, @@ -11,7 +11,7 @@ import { type LeaseHolder, type SendStart, type StoreFactory, -} from "../src/index.js"; +} from "../../src/index.js"; import { MemoryStore } from "./memory-store.js"; interface LeaseRow { diff --git a/test/memory-store.ts b/test/_helpers/memory-store.ts similarity index 99% rename from test/memory-store.ts rename to test/_helpers/memory-store.ts index 318bcb93..4127afe4 100644 --- a/test/memory-store.ts +++ b/test/_helpers/memory-store.ts @@ -33,7 +33,7 @@ import type { StoreFactory, StoreReceiveOptions, TransformOutputs, -} from "../src/index.js"; +} from "../../src/index.js"; /** The status a message takes from what its transform gave, as the store works it out. */ function statusOf(outputs: TransformOutputs): MessageStatus { diff --git a/test/mllp-helpers.ts b/test/_helpers/mllp-helpers.ts similarity index 100% rename from test/mllp-helpers.ts rename to test/_helpers/mllp-helpers.ts diff --git a/test/net-helpers.ts b/test/_helpers/net-helpers.ts similarity index 100% rename from test/net-helpers.ts rename to test/_helpers/net-helpers.ts diff --git a/test/node-memory-store.ts b/test/_helpers/node-memory-store.ts similarity index 89% rename from test/node-memory-store.ts rename to test/_helpers/node-memory-store.ts index 9f160269..3b35b4f3 100644 --- a/test/node-memory-store.ts +++ b/test/_helpers/node-memory-store.ts @@ -1,8 +1,8 @@ -// The in-memory store of test/memory-store.ts with the node methods a custom store may add, written -// as a user would add them: one row per node id, every time from one clock (here this process's, -// standing in for a database's). Every store this module makes shares the rows, as engines on one -// database share its table. Given `options.fail`, a method rejects, for the tests of what the -// engine does then. +// The in-memory store of test/_helpers/memory-store.ts with the node methods a custom store may +// add, written as a user would add them: one row per node id, every time from one clock (here this +// process's, standing in for a database's). Every store this module makes shares the rows, as +// engines on one database share its table. Given `options.fail`, a method rejects, for the tests of +// what the engine does then. import type { NodeInfo, NodeJoin, @@ -11,7 +11,7 @@ import type { NodeSelf, NodeState, StoreFactory, -} from "../src/index.js"; +} from "../../src/index.js"; import { MemoryStore } from "./memory-store.js"; interface Row extends NodeInfo { diff --git a/test/openmetrics.ts b/test/_helpers/openmetrics.ts similarity index 100% rename from test/openmetrics.ts rename to test/_helpers/openmetrics.ts diff --git a/test/receive-keys.ts b/test/_helpers/receive-keys.ts similarity index 94% rename from test/receive-keys.ts rename to test/_helpers/receive-keys.ts index 2645b233..e5cbb65a 100644 --- a/test/receive-keys.ts +++ b/test/_helpers/receive-keys.ts @@ -1,7 +1,7 @@ // Run by test/receive-race.test.ts as a process of its own: opens the SQLite store at argv[2] and // hands in, resumed, one synthetic note under each of argv[3] idempotency keys, in order, then // prints how many the store answered as already stored. -import { Store } from "../src/storage/store.js"; +import { Store } from "../../src/storage/store.js"; async function main(): Promise { const [file = "", count = "0"] = process.argv.slice(2); diff --git a/test/secret-vault.ts b/test/_helpers/secret-vault.ts similarity index 94% rename from test/secret-vault.ts rename to test/_helpers/secret-vault.ts index 2d5a1a4c..5e0494cf 100644 --- a/test/secret-vault.ts +++ b/test/_helpers/secret-vault.ts @@ -3,8 +3,12 @@ // holds the secrets its options give it, so a test needs no cloud store, and notes each provider it // builds on a global, where the tests read the calls it was given. Every value is synthetic. -import { fakeSecretProvider, type FakeSecretEntry, type FakeSecretProvider } from "../src/index.js"; -import type { SecretProvider, SecretProviderFactory } from "../src/index.js"; +import { + fakeSecretProvider, + type FakeSecretEntry, + type FakeSecretProvider, +} from "../../src/index.js"; +import type { SecretProvider, SecretProviderFactory } from "../../src/index.js"; interface VaultOptions { /** The secrets it holds, by name. */ diff --git a/test/smtp-peer.ts b/test/_helpers/smtp-peer.ts similarity index 100% rename from test/smtp-peer.ts rename to test/_helpers/smtp-peer.ts diff --git a/test/ssh-keys.ts b/test/_helpers/ssh-keys.ts similarity index 100% rename from test/ssh-keys.ts rename to test/_helpers/ssh-keys.ts diff --git a/test/sshd.ts b/test/_helpers/sshd.ts similarity index 100% rename from test/sshd.ts rename to test/_helpers/sshd.ts diff --git a/test/batch-crash.test.ts b/test/batch-crash.test.ts index 492367ca..8eaf4295 100644 --- a/test/batch-crash.test.ts +++ b/test/batch-crash.test.ts @@ -21,8 +21,8 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { cleanUp, dropFile, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; afterEach(async () => { await dropDatabases(); diff --git a/test/batch-engine.test.ts b/test/batch-engine.test.ts index 6d44aefb..7eb6effa 100644 --- a/test/batch-engine.test.ts +++ b/test/batch-engine.test.ts @@ -8,7 +8,7 @@ import { Engine } from "../src/engine/engine.js"; import { AuditLog } from "../src/operator/audit.js"; import { type MessageStore, Store } from "../src/storage/store.js"; import { runChannelTests } from "../src/testing/run-tests.js"; -import { ADT_A01, captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; +import { ADT_A01, captureLogger, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/batch.test.ts b/test/batch.test.ts index b5832be8..ddc81bb3 100644 --- a/test/batch.test.ts +++ b/test/batch.test.ts @@ -19,9 +19,14 @@ import { type ReceivedPiece, type ReceiveOptions, } from "../src/connectors/types.js"; -import { FakeLocation } from "./fake-location.js"; -import { ADT_A01, cleanUp, dropFile, makeProject } from "./helpers.js"; -import { makeCertificates, removeCertificates, send, type Certificates } from "./net-helpers.js"; +import { FakeLocation } from "./_helpers/fake-location.js"; +import { ADT_A01, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; +import { + makeCertificates, + removeCertificates, + send, + type Certificates, +} from "./_helpers/net-helpers.js"; afterEach(cleanUp); diff --git a/test/bulk-replay.test.ts b/test/bulk-replay.test.ts index ddaa02b4..a038b346 100644 --- a/test/bulk-replay.test.ts +++ b/test/bulk-replay.test.ts @@ -20,7 +20,7 @@ import { TEST_DATABASES, testStorage, type TestDatabase, -} from "./databases.js"; +} from "./_helpers/databases.js"; import { ADT_A01, captureLogger, @@ -28,7 +28,7 @@ import { dropFile, LAB_TRANSFORM, makeProject, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; const stores: Store[] = []; diff --git a/test/channel-control.test.ts b/test/channel-control.test.ts index 3a03b98e..ab94d208 100644 --- a/test/channel-control.test.ts +++ b/test/channel-control.test.ts @@ -22,8 +22,8 @@ import { TEST_DATABASES, testStorage, type TestDatabase, -} from "./databases.js"; -import { ADT_A01, captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { ADT_A01, captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./_helpers/helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/channel-routing.test.ts b/test/channel-routing.test.ts index 6f3d398b..49ba856b 100644 --- a/test/channel-routing.test.ts +++ b/test/channel-routing.test.ts @@ -32,8 +32,8 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { captureLogger, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/channel-scripts.test.ts b/test/channel-scripts.test.ts index 1b405806..4564f239 100644 --- a/test/channel-scripts.test.ts +++ b/test/channel-scripts.test.ts @@ -26,8 +26,8 @@ import { } from "../src/engine/worker-entry.js"; import { AuditLog } from "../src/operator/audit.js"; import { recordEngineStart, recordEngineStop } from "../src/operator/engine-audit.js"; -import { MemoryStore } from "./memory-store.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; const workers: ChannelWorker[] = []; const engines: Engine[] = []; diff --git a/test/channel-worker.test.ts b/test/channel-worker.test.ts index dd6da7db..ce9c89bb 100644 --- a/test/channel-worker.test.ts +++ b/test/channel-worker.test.ts @@ -11,7 +11,7 @@ import { TransformLoadError, type ChannelWorkerOptions, } from "../src/engine/channel-worker.js"; -import { ADT_A01, cleanUp, LAB_TRANSFORM, makeProject } from "./helpers.js"; +import { ADT_A01, cleanUp, LAB_TRANSFORM, makeProject } from "./_helpers/helpers.js"; const workers: ChannelWorker[] = []; diff --git a/test/claims-and-links.test.ts b/test/claims-and-links.test.ts index bb7ce575..fb0bc3aa 100644 --- a/test/claims-and-links.test.ts +++ b/test/claims-and-links.test.ts @@ -37,9 +37,16 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { ADT_A01, ADT_A08, captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; -import { receiver, type Receiver } from "./net-helpers.js"; +} from "./_helpers/databases.js"; +import { + ADT_A01, + ADT_A08, + captureLogger, + cleanUp, + dropFile, + makeProject, +} from "./_helpers/helpers.js"; +import { receiver, type Receiver } from "./_helpers/net-helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/cli-edges.test.ts b/test/cli-edges.test.ts index 5705a7a8..cf04e9b7 100644 --- a/test/cli-edges.test.ts +++ b/test/cli-edges.test.ts @@ -6,8 +6,8 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { EXIT, run, type CliIo } from "../src/cli.js"; import { generateKey } from "../src/encryption/keys.js"; -import { MEMORY_STORE_FILE } from "./extension-helpers.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { MEMORY_STORE_FILE } from "./_helpers/extension-helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; afterEach(async () => { vi.unstubAllEnvs(); diff --git a/test/cli-lease.test.ts b/test/cli-lease.test.ts index 924cda25..78ad4fac 100644 --- a/test/cli-lease.test.ts +++ b/test/cli-lease.test.ts @@ -12,7 +12,7 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { EXIT, run } from "../src/cli.js"; import { generateKey } from "../src/encryption/keys.js"; import { ENGINE_LEASE, Store, type AuditEntry } from "../src/storage/store.js"; -import { MEMORY_STORE_FILE } from "./extension-helpers.js"; +import { MEMORY_STORE_FILE } from "./_helpers/extension-helpers.js"; import { ADT_A01, captureLogger, @@ -20,8 +20,8 @@ import { dropFile, makeProject, type LogEvent, -} from "./helpers.js"; -import { onPickedPorts, orTaken } from "./net-helpers.js"; +} from "./_helpers/helpers.js"; +import { onPickedPorts, orTaken } from "./_helpers/net-helpers.js"; afterEach(cleanUp); @@ -35,7 +35,7 @@ beforeEach(async () => { }); const KEYS = "encryption:\n keys: [{ id: test, file: ./test.key }]\n current: test\n"; -const LEASED_STORE_FILE = join(import.meta.dirname, "lease-memory-store.ts"); +const LEASED_STORE_FILE = join(import.meta.dirname, "_helpers", "lease-memory-store.ts"); const CHANNEL = "source:\n file: { dir: ../../data/inbox, minAge: 0 }\ndestinations:\n - file: { dir: ../../data/out }\n"; diff --git a/test/cli-migrate.test.ts b/test/cli-migrate.test.ts index 0e693014..bc63a0d9 100644 --- a/test/cli-migrate.test.ts +++ b/test/cli-migrate.test.ts @@ -24,8 +24,8 @@ import { } from "../src/storage/schema.js"; import { Store, type AuditEntry } from "../src/storage/store.js"; import { VERSION } from "../src/version.js"; -import { MEMORY_STORE_FILE } from "./extension-helpers.js"; -import { ADT_A01, cleanUp, dropFile, makeProject } from "./helpers.js"; +import { MEMORY_STORE_FILE } from "./_helpers/extension-helpers.js"; +import { ADT_A01, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/cli-nodes.test.ts b/test/cli-nodes.test.ts index 15aeae48..b2ec4216 100644 --- a/test/cli-nodes.test.ts +++ b/test/cli-nodes.test.ts @@ -17,7 +17,7 @@ import { NODE_ID_FILE } from "../src/engine/nodes.js"; import { generateKey } from "../src/encryption/keys.js"; import { Store, type AuditEntry, type NodeInfo, type NodeRow } from "../src/storage/store.js"; import { VERSION } from "../src/version.js"; -import { MEMORY_STORE_FILE } from "./extension-helpers.js"; +import { MEMORY_STORE_FILE } from "./_helpers/extension-helpers.js"; import { ADT_A01, captureLogger, @@ -25,11 +25,11 @@ import { dropFile, makeProject, type LogEvent, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; afterEach(cleanUp); -const NODE_STORE_FILE = join(import.meta.dirname, "node-memory-store.ts"); +const NODE_STORE_FILE = join(import.meta.dirname, "_helpers", "node-memory-store.ts"); // The node store's rows outlive a test, as a database's would: each test starts with none. The CLI // loads the module by its file URL, so this import is the same instance. diff --git a/test/cli-operator.test.ts b/test/cli-operator.test.ts index 6bd3a8fc..d6f2753a 100644 --- a/test/cli-operator.test.ts +++ b/test/cli-operator.test.ts @@ -11,7 +11,7 @@ import { isEncrypted, isEncryptedText } from "../src/encryption/envelope.js"; import { generateKey } from "../src/encryption/keys.js"; import { parseTime, safeError } from "../src/operator/commands.js"; import { Store, type AuditEntry } from "../src/storage/store.js"; -import { freshBench, RECORD_HOOK } from "./extension-helpers.js"; +import { freshBench, RECORD_HOOK } from "./_helpers/extension-helpers.js"; import { ADT_A01, ADT_A08, @@ -20,7 +20,7 @@ import { dropFile, LAB_TRANSFORM, makeProject, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/cli-secrets-check.test.ts b/test/cli-secrets-check.test.ts index 83cecf23..2e547715 100644 --- a/test/cli-secrets-check.test.ts +++ b/test/cli-secrets-check.test.ts @@ -3,11 +3,11 @@ import { fileURLToPath } from "node:url"; import { afterEach, describe, expect, it } from "vitest"; import { EXIT, run } from "../src/cli.js"; -import { outputs } from "./docs-helpers.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; -import { built } from "./secret-vault.js"; +import { outputs } from "./_helpers/docs-helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; +import { built } from "./_helpers/secret-vault.js"; -const VAULT = fileURLToPath(new URL("./secret-vault.ts", import.meta.url)); +const VAULT = fileURLToPath(new URL("./_helpers/secret-vault.ts", import.meta.url)); // Every value here is synthetic and plainly fake. Each is long and shares no word with the output, // so the redaction test can look for any piece of it in what the command printed and logged. diff --git a/test/cli-unexpected.test.ts b/test/cli-unexpected.test.ts index 9087d534..504da08b 100644 --- a/test/cli-unexpected.test.ts +++ b/test/cli-unexpected.test.ts @@ -15,7 +15,7 @@ import { Engine } from "../src/engine/engine.js"; import type * as StorageOpen from "../src/storage/open.js"; import { openRawStore, openStore } from "../src/storage/open.js"; import { Store } from "../src/storage/store.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; vi.mock("../src/config/load.js", async (original) => { const actual = await original(); diff --git a/test/cli-validate.test.ts b/test/cli-validate.test.ts index dcd00d1e..0adf1d90 100644 --- a/test/cli-validate.test.ts +++ b/test/cli-validate.test.ts @@ -1,7 +1,7 @@ import { afterEach, describe, expect, it } from "vitest"; import { EXIT, run } from "../src/cli.js"; -import { captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./helpers.js"; +import { captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/cli.test.ts b/test/cli.test.ts index 3d08d81b..c3e575a1 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -17,7 +17,7 @@ import { dropFile, LAB_TRANSFORM, makeProject, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; import { CLOSED_PORT, onPickedPorts, @@ -27,7 +27,7 @@ import { send, status, type PickOptions, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; afterEach(cleanUp); diff --git a/test/config-edges.test.ts b/test/config-edges.test.ts index c6b8b849..5843f42d 100644 --- a/test/config-edges.test.ts +++ b/test/config-edges.test.ts @@ -7,7 +7,7 @@ import { join } from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; import { ConfigError, loadProject } from "../src/config/load.js"; -import { cleanUp, makeProject } from "./helpers.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; /** Paths the file system says do not exist, though they do: a folder removed meanwhile. */ const gone = new Set(); diff --git a/test/config-env.test.ts b/test/config-env.test.ts index 9aa8ba50..8d169c9a 100644 --- a/test/config-env.test.ts +++ b/test/config-env.test.ts @@ -17,7 +17,7 @@ import { import { AuditLog } from "../src/operator/audit.js"; import { configFingerprints, recordConfigChanges } from "../src/operator/config-audit.js"; import { Store } from "../src/storage/store.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; /** * Settings written as `{ env: NAME, default? }`: read from the environment named when the project diff --git a/test/config-json-schema.test.ts b/test/config-json-schema.test.ts index 1ed64d06..b3b5c8f2 100644 --- a/test/config-json-schema.test.ts +++ b/test/config-json-schema.test.ts @@ -6,7 +6,7 @@ import { describe, expect, it } from "vitest"; import { parse as parseYaml } from "yaml"; import { channelSchema, configJsonSchemas, FORMATS, projectSchema } from "../src/config/schema.js"; -import { DOCS_DIR, fences, pagePaths, ROOT } from "./docs-helpers.js"; +import { DOCS_DIR, fences, pagePaths, ROOT } from "./_helpers/docs-helpers.js"; /** * The JSON Schemas the build ships for `channel.yaml` and `pathways.yaml`, held to the Zod schemas diff --git a/test/config.test.ts b/test/config.test.ts index ec706dc6..9f0b4155 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -4,7 +4,7 @@ import { afterEach, describe, expect, it } from "vitest"; import { ConfigError, loadProject } from "../src/config/load.js"; import { DEFAULT_SETTINGS, MAX_REGEX_LENGTH } from "../src/config/schema.js"; -import { cleanUp, makeProject } from "./helpers.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/connector-runtime.test.ts b/test/connector-runtime.test.ts index 1ae793f1..5f4af96a 100644 --- a/test/connector-runtime.test.ts +++ b/test/connector-runtime.test.ts @@ -16,8 +16,8 @@ import type { } from "../src/connectors/types.js"; import { Engine, type EngineWait } from "../src/engine/engine.js"; import { Store } from "../src/storage/store.js"; -import { eventually, freshBench, RECORD_HOOK, type Bench } from "./extension-helpers.js"; -import { captureLogger, cleanUp, makeProject, type LogEvent } from "./helpers.js"; +import { eventually, freshBench, RECORD_HOOK, type Bench } from "./_helpers/extension-helpers.js"; +import { captureLogger, cleanUp, makeProject, type LogEvent } from "./_helpers/helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/content-drop.test.ts b/test/content-drop.test.ts index d20bc37d..7246be32 100644 --- a/test/content-drop.test.ts +++ b/test/content-drop.test.ts @@ -23,7 +23,7 @@ import { TEST_DATABASES, testStorage, type TestDatabase, -} from "./databases.js"; +} from "./_helpers/databases.js"; import { ADT_A01, captureLogger, @@ -32,8 +32,8 @@ import { LAB_TRANSFORM, makeProject, type LogEvent, -} from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; +} from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; const closables: { close(): Promise }[] = []; diff --git a/test/content-none.test.ts b/test/content-none.test.ts index 58f16bbe..ef08642d 100644 --- a/test/content-none.test.ts +++ b/test/content-none.test.ts @@ -31,8 +31,15 @@ import { LAB_TRANSFORM, makeProject, type LogEvent, -} from "./helpers.js"; -import { ackText, controlIdOf, exchange, msaOf, startPeer, type Peer } from "./mllp-helpers.js"; +} from "./_helpers/helpers.js"; +import { + ackText, + controlIdOf, + exchange, + msaOf, + startPeer, + type Peer, +} from "./_helpers/mllp-helpers.js"; import { onPickedPorts, receiver, @@ -40,7 +47,7 @@ import { sourceListening, status, type Receiver, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/control.test.ts b/test/control.test.ts index 0a54ed64..ee163311 100644 --- a/test/control.test.ts +++ b/test/control.test.ts @@ -32,7 +32,7 @@ import { dropFile, LAB_TRANSFORM, makeProject, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; const unix = process.platform !== "win32"; const servers: ControlServer[] = []; diff --git a/test/cron-load-failure.test.ts b/test/cron-load-failure.test.ts index 39791ad9..21325774 100644 --- a/test/cron-load-failure.test.ts +++ b/test/cron-load-failure.test.ts @@ -5,7 +5,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { ConfigError, loadProject } from "../src/config/load.js"; -import { cleanUp, makeProject } from "./helpers.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; const loader: { thrown: unknown } = vi.hoisted(() => ({ thrown: undefined })); diff --git a/test/csv-format.test.ts b/test/csv-format.test.ts index 9b214409..dbf5e425 100644 --- a/test/csv-format.test.ts +++ b/test/csv-format.test.ts @@ -20,8 +20,8 @@ import { writeCsv, type CsvSettings, } from "../src/engine/worker-entry.js"; -import { TEST_DATABASES, testStorage } from "./databases.js"; -import { captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; +import { TEST_DATABASES, testStorage } from "./_helpers/databases.js"; +import { captureLogger, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; // Every cell below is synthetic: codes and names that are plainly fake. diff --git a/test/delivery-queued-at.test.ts b/test/delivery-queued-at.test.ts index bdb8bb0d..ab046022 100644 --- a/test/delivery-queued-at.test.ts +++ b/test/delivery-queued-at.test.ts @@ -22,8 +22,8 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { cleanUp, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; const stores: Store[] = []; const connections: Kysely[] = []; diff --git a/test/destination-identity.test.ts b/test/destination-identity.test.ts index f3268235..91b77801 100644 --- a/test/destination-identity.test.ts +++ b/test/destination-identity.test.ts @@ -20,9 +20,15 @@ import { showCommand } from "../src/operator/commands.js"; import { verifyCommand } from "../src/operator/verify.js"; import { ENGINE_LEASE } from "../src/storage/lease.js"; import { Store, type MessageStore } from "../src/storage/store.js"; -import { available, closeAdmins, dropDatabases, TEST_DATABASES, testStorage } from "./databases.js"; -import { captureLogger, cleanUp, makeProject, type LogEvent } from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; +import { + available, + closeAdmins, + dropDatabases, + TEST_DATABASES, + testStorage, +} from "./_helpers/databases.js"; +import { captureLogger, cleanUp, makeProject, type LogEvent } from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/destination-transform.test.ts b/test/destination-transform.test.ts index fbff382d..89f55361 100644 --- a/test/destination-transform.test.ts +++ b/test/destination-transform.test.ts @@ -47,9 +47,15 @@ import { TEST_DATABASES, testStorage, type TestDatabase, -} from "./databases.js"; -import { captureLogger, cleanUp, dropFile, makeProject, type LogEvent } from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; +} from "./_helpers/databases.js"; +import { + captureLogger, + cleanUp, + dropFile, + makeProject, + type LogEvent, +} from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; const workers: ChannelWorker[] = []; const engines: Engine[] = []; diff --git a/test/dialects.test.ts b/test/dialects.test.ts index 99c879b3..f05552ad 100644 --- a/test/dialects.test.ts +++ b/test/dialects.test.ts @@ -13,8 +13,8 @@ import { type DriverPackage, } from "../src/storage/dialects.js"; import { StorageError, Store } from "../src/storage/store.js"; -import { serverStorage, URL_ENV } from "./databases.js"; -import { makeCertificates, removeCertificates, type Certificates } from "./net-helpers.js"; +import { serverStorage, URL_ENV } from "./_helpers/databases.js"; +import { makeCertificates, removeCertificates, type Certificates } from "./_helpers/net-helpers.js"; let certs: Certificates | undefined; beforeAll(() => { diff --git a/test/docs-content.test.ts b/test/docs-content.test.ts index 44c25ae2..c953b1cc 100644 --- a/test/docs-content.test.ts +++ b/test/docs-content.test.ts @@ -40,9 +40,9 @@ import { starterProject, startEngine, titled, -} from "./docs-helpers.js"; -import { ADT_A01, ADT_A08, FHIR_PATIENT, X12_270 } from "./helpers.js"; -import { onPickedPorts, orTaken } from "./net-helpers.js"; +} from "./_helpers/docs-helpers.js"; +import { ADT_A01, ADT_A08, FHIR_PATIENT, X12_270 } from "./_helpers/helpers.js"; +import { onPickedPorts, orTaken } from "./_helpers/net-helpers.js"; /** * The docs.cosyte.com pages in `docs-content/`, held to the code they describe. diff --git a/test/drain-process.test.ts b/test/drain-process.test.ts index 3c4e820b..07b95b43 100644 --- a/test/drain-process.test.ts +++ b/test/drain-process.test.ts @@ -24,8 +24,8 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { cleanUp, dropFile, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; afterEach(async () => { await dropDatabases(); diff --git a/test/drain.test.ts b/test/drain.test.ts index 94448c00..b20894b5 100644 --- a/test/drain.test.ts +++ b/test/drain.test.ts @@ -35,9 +35,9 @@ import { LAB_TRANSFORM, makeProject, type LogEvent, -} from "./helpers.js"; -import { msaOf } from "./mllp-helpers.js"; -import { onPickedPorts, orTaken } from "./net-helpers.js"; +} from "./_helpers/helpers.js"; +import { msaOf } from "./_helpers/mllp-helpers.js"; +import { onPickedPorts, orTaken } from "./_helpers/net-helpers.js"; const sources: MllpSource[] = []; const gates: (() => void)[] = []; diff --git a/test/dry-run.test.ts b/test/dry-run.test.ts index 95763176..7f41be0c 100644 --- a/test/dry-run.test.ts +++ b/test/dry-run.test.ts @@ -20,10 +20,10 @@ import { dropFile, LAB_TRANSFORM, makeProject, -} from "./helpers.js"; -import { built } from "./secret-vault.js"; +} from "./_helpers/helpers.js"; +import { built } from "./_helpers/secret-vault.js"; -const VAULT = fileURLToPath(new URL("./secret-vault.ts", import.meta.url)); +const VAULT = fileURLToPath(new URL("./_helpers/secret-vault.ts", import.meta.url)); afterEach(cleanUp); diff --git a/test/encrypted-store.test.ts b/test/encrypted-store.test.ts index 208d8f8d..7f8f603d 100644 --- a/test/encrypted-store.test.ts +++ b/test/encrypted-store.test.ts @@ -28,8 +28,15 @@ import { freshDatabase, TEST_DATABASES, type TestDatabase, -} from "./databases.js"; -import { ADT_A01, ADT_A08, captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { + ADT_A01, + ADT_A08, + captureLogger, + cleanUp, + dropFile, + makeProject, +} from "./_helpers/helpers.js"; const open: { close(): Promise }[] = []; diff --git a/test/encryption-cli.test.ts b/test/encryption-cli.test.ts index 2aae8911..2d505aa1 100644 --- a/test/encryption-cli.test.ts +++ b/test/encryption-cli.test.ts @@ -12,7 +12,7 @@ import { decodeKey, generateKey, LocalKeyProvider } from "../src/encryption/keys import type { RekeyCounts } from "../src/encryption/rekey.js"; import { destinationKeys } from "../src/engine/destination-key.js"; import { Store } from "../src/storage/store.js"; -import { freshBench } from "./extension-helpers.js"; +import { freshBench } from "./_helpers/extension-helpers.js"; import { ADT_A01, captureLogger, @@ -21,7 +21,7 @@ import { LAB_TRANSFORM, makeProject, type LogEvent, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/encryption.test.ts b/test/encryption.test.ts index 9803ee69..07da43f4 100644 --- a/test/encryption.test.ts +++ b/test/encryption.test.ts @@ -27,7 +27,7 @@ import { type KeyProvider, } from "../src/encryption/keys.js"; import { configuredName } from "../src/env.js"; -import { ADT_A01, cleanUp, makeProject } from "./helpers.js"; +import { ADT_A01, cleanUp, makeProject } from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/endpoint.test.ts b/test/endpoint.test.ts index 318cdd29..c0e05064 100644 --- a/test/endpoint.test.ts +++ b/test/endpoint.test.ts @@ -17,7 +17,12 @@ import { } from "../src/connectors/endpoint.js"; import { loadClientTls, loadServerTls, serverTlsOptions } from "../src/connectors/tls.js"; import { configuredName } from "../src/env.js"; -import { makeCertificates, removeCertificates, send, type Certificates } from "./net-helpers.js"; +import { + makeCertificates, + removeCertificates, + send, + type Certificates, +} from "./_helpers/net-helpers.js"; // Wraps the real timingSafeEqual so a test can see that token checks go through it. vi.mock("node:crypto", async (importOriginal) => { diff --git a/test/engine-edges.test.ts b/test/engine-edges.test.ts index ad201b73..51745343 100644 --- a/test/engine-edges.test.ts +++ b/test/engine-edges.test.ts @@ -5,8 +5,8 @@ import { afterEach, describe, expect, it } from "vitest"; import { loadProject } from "../src/config/load.js"; import { Engine } from "../src/engine/engine.js"; import { Store } from "../src/storage/store.js"; -import { freshBench, POLL_SOURCE, RECORD_HOOK } from "./extension-helpers.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { freshBench, POLL_SOURCE, RECORD_HOOK } from "./_helpers/extension-helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/engine-http.test.ts b/test/engine-http.test.ts index 9b4cc0ee..1dbe3fde 100644 --- a/test/engine-http.test.ts +++ b/test/engine-http.test.ts @@ -22,7 +22,7 @@ import { SECOND_HEADER_BEHIND, SECOND_HEADER_JOINED, type LogEvent, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; import { CLOSED_PORT, makeCertificates, @@ -36,7 +36,7 @@ import { type Certificates, type PickOptions, type Receiver, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; const TOKEN = "synthetic-token-0123456789abcdef"; const HEALTH_TOKEN = "synthetic-health-token-0123456789"; diff --git a/test/engine-memory.test.ts b/test/engine-memory.test.ts index 8e8b3d59..2efa97eb 100644 --- a/test/engine-memory.test.ts +++ b/test/engine-memory.test.ts @@ -21,7 +21,7 @@ import { EncryptedStore } from "../src/encryption/encrypted-store.js"; import { KEY_BYTES, LocalKeyProvider } from "../src/encryption/keys.js"; import { Engine } from "../src/engine/engine.js"; import { Store } from "../src/storage/store.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; afterEach(async () => { vi.restoreAllMocks(); diff --git a/test/engine-stop.test.ts b/test/engine-stop.test.ts index 4a717d30..9b4b6d12 100644 --- a/test/engine-stop.test.ts +++ b/test/engine-stop.test.ts @@ -21,8 +21,14 @@ import { afterEach, describe, expect, it } from "vitest"; import { generateKey } from "../src/encryption/keys.js"; import { Store } from "../src/storage/store.js"; -import { leaseLapsed } from "./databases.js"; -import { ADT_A01, cleanUp, dropFileWhileRunning, LAB_TRANSFORM, makeProject } from "./helpers.js"; +import { leaseLapsed } from "./_helpers/databases.js"; +import { + ADT_A01, + cleanUp, + dropFileWhileRunning, + LAB_TRANSFORM, + makeProject, +} from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/engine.test.ts b/test/engine.test.ts index e3d481ef..6efa5a7e 100644 --- a/test/engine.test.ts +++ b/test/engine.test.ts @@ -29,7 +29,7 @@ import { TEST_DATABASES, testStorage, type TestDatabase, -} from "./databases.js"; +} from "./_helpers/databases.js"; import { ADT_A01, ADT_A08, @@ -42,7 +42,7 @@ import { makeProject, X12_270, type LogEvent, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/env-access.test.ts b/test/env-access.test.ts index d786bdac..47ade8dd 100644 --- a/test/env-access.test.ts +++ b/test/env-access.test.ts @@ -1,9 +1,9 @@ /** * src/env.ts is the one place in src/ that reads the process's environment, and the lint rule in * eslint.config.js holds every other file to it. Here ESLint, with the rules the gate's own - * configuration gives a file in src/, lints each case in test/env-access-cases.ts: every way a - * reviewer found to reach a variable without src/env.ts is refused, and ordinary uses of `process` - * and of an environment object handed along are not. + * configuration gives a file in src/, lints each case in test/_helpers/env-access-cases.ts: every + * way a reviewer found to reach a variable without src/env.ts is refused, and ordinary uses of + * `process` and of an environment object handed along are not. */ import { readdirSync, readFileSync } from "node:fs"; @@ -23,7 +23,7 @@ import { processEnv, } from "../src/env.js"; -import { ALLOWED, REFUSED } from "./env-access-cases.js"; +import { ALLOWED, REFUSED } from "./_helpers/env-access-cases.js"; const ROOT = join(import.meta.dirname, ".."); diff --git a/test/env-example.test.ts b/test/env-example.test.ts index 8cf8d0b6..cd86c322 100644 --- a/test/env-example.test.ts +++ b/test/env-example.test.ts @@ -5,9 +5,9 @@ * with `ENGINE_VARIABLES`, the list src/env.ts exports of the variables Pathways reads by a fixed * name: each lists every entry, under a comment of its own with a placeholder in place of any * secret, and no other variable but the example's Compose variables. What keeps that list whole is - * elsewhere: the type checker (test/env-types.ts) and the lint rule (test/env-access.test.ts) - * refuse the listed ways of reading a fixed-name variable outside it, and any other route is - * caught by review, not by a check. + * elsewhere: the type checker (test/_helpers/env-types.ts) and the lint rule + * (test/env-access.test.ts) refuse the listed ways of reading a fixed-name variable outside it, + * and any other route is caught by review, not by a check. * - The Compose example lists every variable its `compose.yaml` and its configuration name. * - The starter carries the same `compose.yaml` and `.env.example` as the example, and the example's * channel is the starter's. diff --git a/test/examples.test.ts b/test/examples.test.ts index ad39dcbf..1c6a2f0a 100644 --- a/test/examples.test.ts +++ b/test/examples.test.ts @@ -30,10 +30,10 @@ import { sidebarIds, } from "../scripts/example-pages.js"; import { run } from "../src/cli.js"; -import { outputs, ROOT } from "./docs-helpers.js"; -import { captureLogger, type LogEvent } from "./helpers.js"; -import { onPickedPorts, PortTaken } from "./net-helpers.js"; -import { SSHD, startSshd, stopAllSshd } from "./sshd.js"; +import { outputs, ROOT } from "./_helpers/docs-helpers.js"; +import { captureLogger, type LogEvent } from "./_helpers/helpers.js"; +import { onPickedPorts, PortTaken } from "./_helpers/net-helpers.js"; +import { SSHD, startSshd, stopAllSshd } from "./_helpers/sshd.js"; /** * The example projects in `examples/`, each held to its README and its page in `docs-content/`: diff --git a/test/extension-encryption.test.ts b/test/extension-encryption.test.ts index 2232af8c..805ed903 100644 --- a/test/extension-encryption.test.ts +++ b/test/extension-encryption.test.ts @@ -7,7 +7,7 @@ import { EXIT, run } from "../src/cli.js"; import { loadProject, type ConfigError } from "../src/config/load.js"; import { generateKey } from "../src/encryption/keys.js"; import { Store } from "../src/storage/store.js"; -import { freshBench, MEMORY_STORE_FILE, RECORD_HOOK } from "./extension-helpers.js"; +import { freshBench, MEMORY_STORE_FILE, RECORD_HOOK } from "./_helpers/extension-helpers.js"; import { ADT_A01, captureLogger, @@ -16,8 +16,8 @@ import { LAB_TRANSFORM, makeProject, type LogEvent, -} from "./helpers.js"; -import { opened } from "./memory-store.js"; +} from "./_helpers/helpers.js"; +import { opened } from "./_helpers/memory-store.js"; afterEach(cleanUp); diff --git a/test/extension-types.test.ts b/test/extension-types.test.ts index cbf986b6..030e93d7 100644 --- a/test/extension-types.test.ts +++ b/test/extension-types.test.ts @@ -24,7 +24,7 @@ import { type StoreFactory, type TransformFailureKind, } from "../src/index.js"; -import { MemoryStore } from "./memory-store.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; // --- Extensions, written as a user would write them ----------------------------------------------- diff --git a/test/extensions.test.ts b/test/extensions.test.ts index 546ac3f1..376cb147 100644 --- a/test/extensions.test.ts +++ b/test/extensions.test.ts @@ -25,7 +25,7 @@ import { LISTEN_SOURCE, MEMORY_STORE_FILE, POLL_SOURCE, -} from "./extension-helpers.js"; +} from "./_helpers/extension-helpers.js"; import { ADT_A01, ADT_A08, @@ -35,10 +35,10 @@ import { LAB_TRANSFORM, makeProject, type LogEvent, -} from "./helpers.js"; -import { controlIdOf, exchange, msaOf } from "./mllp-helpers.js"; -import { opened } from "./memory-store.js"; -import { CLOSED_PORT, onPickedPorts, sourceListening } from "./net-helpers.js"; +} from "./_helpers/helpers.js"; +import { controlIdOf, exchange, msaOf } from "./_helpers/mllp-helpers.js"; +import { opened } from "./_helpers/memory-store.js"; +import { CLOSED_PORT, onPickedPorts, sourceListening } from "./_helpers/net-helpers.js"; const engines: Engine[] = []; const stores: MessageStore[] = []; diff --git a/test/fault-points.test.ts b/test/fault-points.test.ts index 1424779d..75e96817 100644 --- a/test/fault-points.test.ts +++ b/test/fault-points.test.ts @@ -34,8 +34,8 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { cleanUp, dropFile, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; afterEach(async () => { await dropDatabases(); diff --git a/test/file-location.test.ts b/test/file-location.test.ts index 7cff2872..1017eb2e 100644 --- a/test/file-location.test.ts +++ b/test/file-location.test.ts @@ -5,8 +5,8 @@ import { afterEach, describe, expect, it } from "vitest"; import { CLAIMED_DIR, FileDestination, FileSource } from "../src/connectors/file.js"; import type { MessageSink, ReceiveOptions } from "../src/connectors/types.js"; -import { FakeLocation } from "./fake-location.js"; -import { cleanUp, dropFile, makeProject } from "./helpers.js"; +import { FakeLocation } from "./_helpers/fake-location.js"; +import { cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/file-source-options.test.ts b/test/file-source-options.test.ts index 1c1037f6..137c7ad9 100644 --- a/test/file-source-options.test.ts +++ b/test/file-source-options.test.ts @@ -18,7 +18,7 @@ import { } from "../src/connectors/file.js"; import type { MessageSink, ReceiveOptions } from "../src/connectors/types.js"; import { connectorsFor } from "../src/engine/engine.js"; -import { captureLogger, cleanUp, dropFile, makeProject, usePlatform } from "./helpers.js"; +import { captureLogger, cleanUp, dropFile, makeProject, usePlatform } from "./_helpers/helpers.js"; afterEach(cleanUp); afterEach(() => { diff --git a/test/file-source-race.test.ts b/test/file-source-race.test.ts index 8e9c1e68..ae877cf9 100644 --- a/test/file-source-race.test.ts +++ b/test/file-source-race.test.ts @@ -12,7 +12,7 @@ import { type FileSourceOptions, } from "../src/connectors/file.js"; import type { MessageSink } from "../src/connectors/types.js"; -import { cleanUp, dropFile, makeProject } from "./helpers.js"; +import { cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; /** * `then` runs once, just before the next move whose destination passes `when`, and `after` just diff --git a/test/file-source-sync.test.ts b/test/file-source-sync.test.ts index 464ab0be..eff43f8f 100644 --- a/test/file-source-sync.test.ts +++ b/test/file-source-sync.test.ts @@ -6,7 +6,7 @@ import { afterEach, describe, expect, it, onTestFinished, vi } from "vitest"; import { FileSource } from "../src/connectors/file.js"; import type { MessageSink } from "../src/connectors/types.js"; -import { cleanUp, dropFile, makeProject, usePlatform } from "./helpers.js"; +import { cleanUp, dropFile, makeProject, usePlatform } from "./_helpers/helpers.js"; /** * Each move, each flush to disk and each message handed in, in order; whether a flush of a folder diff --git a/test/file-source.test.ts b/test/file-source.test.ts index f00c6473..14f2c652 100644 --- a/test/file-source.test.ts +++ b/test/file-source.test.ts @@ -5,7 +5,13 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { CLAIMED_DIR, FileSource, PROCESSED_DIR } from "../src/connectors/file.js"; import type { MessageSink, ReceiveOptions } from "../src/connectors/types.js"; -import { cleanUp, dropFile, holdExclusively, makeProject, usePlatform } from "./helpers.js"; +import { + cleanUp, + dropFile, + holdExclusively, + makeProject, + usePlatform, +} from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/format-equivalence.test.ts b/test/format-equivalence.test.ts index 03f54952..24399bfa 100644 --- a/test/format-equivalence.test.ts +++ b/test/format-equivalence.test.ts @@ -17,7 +17,7 @@ import { afterAll, describe, expect, it } from "vitest"; import { run } from "../src/cli.js"; import { expectedName } from "../src/testing/run-tests.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; interface CorpusEntry { readonly id: string; diff --git a/test/hl7v2-charset.test.ts b/test/hl7v2-charset.test.ts index e56f5baf..7d65e529 100644 --- a/test/hl7v2-charset.test.ts +++ b/test/hl7v2-charset.test.ts @@ -6,8 +6,8 @@ import { afterEach, describe, expect, it } from "vitest"; import { loadProject } from "../src/config/load.js"; import { Engine } from "../src/engine/engine.js"; -import { TEST_DATABASES, testStorage } from "./databases.js"; -import { captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; +import { TEST_DATABASES, testStorage } from "./_helpers/databases.js"; +import { captureLogger, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/hooks.test.ts b/test/hooks.test.ts index 3cbd9461..1267dfb0 100644 --- a/test/hooks.test.ts +++ b/test/hooks.test.ts @@ -16,9 +16,9 @@ import { LISTEN_SOURCE, POLL_SOURCE, RECORD_HOOK, -} from "./extension-helpers.js"; -import { captureLogger, cleanUp, makeProject, type LogEvent } from "./helpers.js"; -import { receiver, status, type Receiver } from "./net-helpers.js"; +} from "./_helpers/extension-helpers.js"; +import { captureLogger, cleanUp, makeProject, type LogEvent } from "./_helpers/helpers.js"; +import { receiver, status, type Receiver } from "./_helpers/net-helpers.js"; const engines: Engine[] = []; const stores: MessageStore[] = []; diff --git a/test/http-destination-options.test.ts b/test/http-destination-options.test.ts index 4da8749d..d094c43f 100644 --- a/test/http-destination-options.test.ts +++ b/test/http-destination-options.test.ts @@ -16,8 +16,8 @@ import { import { DeliveryRejected } from "../src/connectors/types.js"; import { Engine } from "../src/engine/engine.js"; import { Store, type MessageStore } from "../src/storage/store.js"; -import { ADT_A01, captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; +import { ADT_A01, captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; import { makeCertificates, receiver, @@ -25,7 +25,7 @@ import { status, type Certificates, type Receiver, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; const receivers: Receiver[] = []; const destinations: HttpDestination[] = []; diff --git a/test/http-destination.test.ts b/test/http-destination.test.ts index 97b53871..bd995353 100644 --- a/test/http-destination.test.ts +++ b/test/http-destination.test.ts @@ -6,7 +6,7 @@ import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; import { HttpDestination, type HttpDestinationOptions } from "../src/connectors/http.js"; import { RedirectHeld, RetryableError } from "../src/connectors/http-core.js"; import { DeliveryRejected } from "../src/connectors/types.js"; -import { ADT_A01 } from "./helpers.js"; +import { ADT_A01 } from "./_helpers/helpers.js"; import { CLOSED_PORT, makeCertificates, @@ -15,7 +15,7 @@ import { status, type Certificates, type Receiver, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; let certs: Certificates; beforeAll(() => { diff --git a/test/http-retry-engine.test.ts b/test/http-retry-engine.test.ts index 5cff641c..f2be8467 100644 --- a/test/http-retry-engine.test.ts +++ b/test/http-retry-engine.test.ts @@ -6,7 +6,7 @@ import { afterEach, describe, expect, it } from "vitest"; import { loadProject } from "../src/config/load.js"; import { Engine, RETRY_MAX_MS, retryWait } from "../src/engine/engine.js"; import { Store } from "../src/storage/store.js"; -import { freshBench, RECORD_HOOK } from "./extension-helpers.js"; +import { freshBench, RECORD_HOOK } from "./_helpers/extension-helpers.js"; import { ADT_A01, captureLogger, @@ -14,8 +14,8 @@ import { dropFile, LAB_TRANSFORM, makeProject, -} from "./helpers.js"; -import { receiver, status, type Receiver } from "./net-helpers.js"; +} from "./_helpers/helpers.js"; +import { receiver, status, type Receiver } from "./_helpers/net-helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/http-source-options.test.ts b/test/http-source-options.test.ts index f30cc6d2..7b6873e0 100644 --- a/test/http-source-options.test.ts +++ b/test/http-source-options.test.ts @@ -4,14 +4,14 @@ import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; import { HttpSource, type HttpSourceOptions } from "../src/connectors/http.js"; import { HL7_MEDIA_TYPES, hl7MediaType, normalisePath } from "../src/connectors/http-path.js"; import type { MessageSink, ReceiveOptions } from "../src/connectors/types.js"; -import { ADT_A01 } from "./helpers.js"; +import { ADT_A01 } from "./_helpers/helpers.js"; import { makeCertificates, removeCertificates, send, type Answer, type Certificates, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; // A synthetic sender against each rule of the HTTP source's options: HL7 over HTTP acknowledgements, // methods, several paths and a configured response. Every message is the synthetic ADT^A01. diff --git a/test/http-source.test.ts b/test/http-source.test.ts index d31fe3bc..960b0b29 100644 --- a/test/http-source.test.ts +++ b/test/http-source.test.ts @@ -4,8 +4,13 @@ import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; import { HttpSource, type HttpSourceOptions } from "../src/connectors/http.js"; import type { MessageSink } from "../src/connectors/types.js"; -import { ADT_A01 } from "./helpers.js"; -import { makeCertificates, removeCertificates, send, type Certificates } from "./net-helpers.js"; +import { ADT_A01 } from "./_helpers/helpers.js"; +import { + makeCertificates, + removeCertificates, + send, + type Certificates, +} from "./_helpers/net-helpers.js"; const TOKEN = "synthetic-token-0123456789abcdef"; const AUTH = { Authorization: `Bearer ${TOKEN}` }; diff --git a/test/http-xml-ack.test.ts b/test/http-xml-ack.test.ts index fd28c5f4..df3a1625 100644 --- a/test/http-xml-ack.test.ts +++ b/test/http-xml-ack.test.ts @@ -10,14 +10,14 @@ import { HttpDestination, type HttpDestinationOptions } from "../src/connectors/ import { RetryableError } from "../src/connectors/http-core.js"; import { DeliveryRejected } from "../src/connectors/types.js"; import { connectorsFor } from "../src/engine/engine.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; import { makeCertificates, receiver, removeCertificates, type Certificates, type Receiver, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; // The XML reader, watched so a test can count how often the message sent is read. const parses = vi.hoisted(() => ({ texts: [] as string[] })); diff --git a/test/init.test.ts b/test/init.test.ts index dddfd095..d25ee9d0 100644 --- a/test/init.test.ts +++ b/test/init.test.ts @@ -14,7 +14,7 @@ import { initProject, STARTER_KEY_FILE, } from "../src/starter/init.js"; -import { captureLogger, cleanUp, makeProject, usePlatform } from "./helpers.js"; +import { captureLogger, cleanUp, makeProject, usePlatform } from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/lease-processes.test.ts b/test/lease-processes.test.ts index fb683921..b98416e7 100644 --- a/test/lease-processes.test.ts +++ b/test/lease-processes.test.ts @@ -34,8 +34,8 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { cleanUp, dropFile, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; const children: ChildProcess[] = []; diff --git a/test/lease-store.test.ts b/test/lease-store.test.ts index 81287df6..8c24b5ce 100644 --- a/test/lease-store.test.ts +++ b/test/lease-store.test.ts @@ -23,9 +23,9 @@ import { TEST_DATABASES, testStorage, type TestStorage, -} from "./databases.js"; -import { cleanUp, makeProject } from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; +} from "./_helpers/databases.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; const stores: Store[] = []; diff --git a/test/meta-index.test.ts b/test/meta-index.test.ts index ebb2b825..7a688b35 100644 --- a/test/meta-index.test.ts +++ b/test/meta-index.test.ts @@ -47,9 +47,9 @@ import { TEST_DATABASES, testStorage, type TestDatabase, -} from "./databases.js"; -import { ADT_A01, captureLogger, cleanUp, makeProject, type LogEvent } from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; +} from "./_helpers/databases.js"; +import { ADT_A01, captureLogger, cleanUp, makeProject, type LogEvent } from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; const open: { close(): Promise }[] = []; diff --git a/test/metrics-engine.test.ts b/test/metrics-engine.test.ts index e33b8e4a..352ecdeb 100644 --- a/test/metrics-engine.test.ts +++ b/test/metrics-engine.test.ts @@ -27,10 +27,17 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { ADT_A01, ADT_A08, captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; -import { onPickedPorts, send, sourceListening } from "./net-helpers.js"; -import { parseOpenMetrics } from "./openmetrics.js"; +} from "./_helpers/databases.js"; +import { + ADT_A01, + ADT_A08, + captureLogger, + cleanUp, + dropFile, + makeProject, +} from "./_helpers/helpers.js"; +import { onPickedPorts, send, sourceListening } from "./_helpers/net-helpers.js"; +import { parseOpenMetrics } from "./_helpers/openmetrics.js"; const TOKEN = "synthetic-token-0123456789abcdef"; diff --git a/test/metrics.test.ts b/test/metrics.test.ts index 217cf81c..be181936 100644 --- a/test/metrics.test.ts +++ b/test/metrics.test.ts @@ -29,7 +29,13 @@ import { } from "../src/engine/metrics.js"; import type { LifecycleEvent } from "../src/extensions/events.js"; import type { Store } from "../src/storage/store.js"; -import { available, closeAdmins, dropDatabases, TEST_DATABASES, testStorage } from "./databases.js"; +import { + available, + closeAdmins, + dropDatabases, + TEST_DATABASES, + testStorage, +} from "./_helpers/databases.js"; import { ADT_A01, ADT_A08, @@ -38,10 +44,10 @@ import { dropFile, LAB_TRANSFORM, makeProject, -} from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; -import { send } from "./net-helpers.js"; -import { parseOpenMetrics } from "./openmetrics.js"; +} from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; +import { send } from "./_helpers/net-helpers.js"; +import { parseOpenMetrics } from "./_helpers/openmetrics.js"; /** 2026-11-10T12:00:00.000Z: every series in the golden text was made then. */ const MADE_AT = Date.UTC(2026, 10, 10, 12, 0, 0); diff --git a/test/mllp-destination.test.ts b/test/mllp-destination.test.ts index a4a5259e..10ba3564 100644 --- a/test/mllp-destination.test.ts +++ b/test/mllp-destination.test.ts @@ -9,14 +9,21 @@ import { type MllpDestinationOptions, } from "../src/connectors/mllp.js"; import { DeliveryRejected } from "../src/connectors/types.js"; -import { ADT_A01 } from "./helpers.js"; -import { ackText, controlIdOf, OPENSSL, startPeer, TLS_TESTS, type Peer } from "./mllp-helpers.js"; +import { ADT_A01 } from "./_helpers/helpers.js"; +import { + ackText, + controlIdOf, + OPENSSL, + startPeer, + TLS_TESTS, + type Peer, +} from "./_helpers/mllp-helpers.js"; import { CLOSED_PORT, makeCertificates, removeCertificates, type Certificates, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; const peers: Peer[] = []; const destinations: MllpDestination[] = []; diff --git a/test/mllp-dial-out.test.ts b/test/mllp-dial-out.test.ts index 839adb97..f15cd6f0 100644 --- a/test/mllp-dial-out.test.ts +++ b/test/mllp-dial-out.test.ts @@ -26,14 +26,14 @@ import { sendOnce, type MllpDialError } from "../src/connectors/mllp-dial.js"; import type { MessageSink, ReceiveOptions } from "../src/connectors/types.js"; import { Engine } from "../src/engine/engine.js"; import { Store } from "../src/storage/store.js"; -import { ADT_A01, captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./helpers.js"; -import { exchange, msaOf, OPENSSL, TLS_TESTS } from "./mllp-helpers.js"; +import { ADT_A01, captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./_helpers/helpers.js"; +import { exchange, msaOf, OPENSSL, TLS_TESTS } from "./_helpers/mllp-helpers.js"; import { CLOSED_PORT, makeCertificates, removeCertificates, type Certificates, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; /* * Two ways an MLLP source reaches beyond the connection a sender opened: replyTo sends each ACK on a diff --git a/test/mllp-engine.test.ts b/test/mllp-engine.test.ts index c83ca773..2b729439 100644 --- a/test/mllp-engine.test.ts +++ b/test/mllp-engine.test.ts @@ -16,7 +16,7 @@ import { LAB_TRANSFORM, makeProject, type LogEvent, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; import { ackText, controlIdOf, @@ -26,7 +26,7 @@ import { startPeer, TLS_TESTS, type Peer, -} from "./mllp-helpers.js"; +} from "./_helpers/mllp-helpers.js"; import { makeCertificates, onPickedPorts, @@ -35,7 +35,7 @@ import { sourceListening, type Certificates, type PickOptions, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/mllp-options.test.ts b/test/mllp-options.test.ts index ad90e45b..65ef4ba7 100644 --- a/test/mllp-options.test.ts +++ b/test/mllp-options.test.ts @@ -33,15 +33,15 @@ import { secretUses } from "../src/secrets/sources.js"; import { Engine } from "../src/engine/engine.js"; import { Store } from "../src/storage/store.js"; import { configuredName } from "../src/env.js"; -import { ADT_A01, captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./helpers.js"; -import { exchange, msaOf, OPENSSL, TLS_TESTS } from "./mllp-helpers.js"; +import { ADT_A01, captureLogger, cleanUp, LAB_TRANSFORM, makeProject } from "./_helpers/helpers.js"; +import { exchange, msaOf, OPENSSL, TLS_TESTS } from "./_helpers/mllp-helpers.js"; import { makeCertificates, onPickedPorts, removeCertificates, sourceListening, type Certificates, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; const sources: MllpSource[] = []; diff --git a/test/mllp-source.test.ts b/test/mllp-source.test.ts index a56f7991..e287364d 100644 --- a/test/mllp-source.test.ts +++ b/test/mllp-source.test.ts @@ -16,9 +16,9 @@ import { joinedResults, SECOND_HEADER_BEHIND, SECOND_HEADER_JOINED, -} from "./helpers.js"; -import { errOf, exchange, msaOf, OPENSSL, TLS_TESTS } from "./mllp-helpers.js"; -import { makeCertificates, removeCertificates, type Certificates } from "./net-helpers.js"; +} from "./_helpers/helpers.js"; +import { errOf, exchange, msaOf, OPENSSL, TLS_TESTS } from "./_helpers/mllp-helpers.js"; +import { makeCertificates, removeCertificates, type Certificates } from "./_helpers/net-helpers.js"; const sources: MllpSource[] = []; diff --git a/test/net-helpers.test.ts b/test/net-helpers.test.ts index ce738f2d..53f4ce03 100644 --- a/test/net-helpers.test.ts +++ b/test/net-helpers.test.ts @@ -13,7 +13,7 @@ import { pickPorts, PortTaken, sourceListening, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; const servers: Server[] = []; afterEach(async () => { diff --git a/test/nodes-processes.test.ts b/test/nodes-processes.test.ts index ce2af386..bcf9b4bf 100644 --- a/test/nodes-processes.test.ts +++ b/test/nodes-processes.test.ts @@ -20,8 +20,8 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { cleanUp, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; const children: ChildProcess[] = []; diff --git a/test/nodes-store.test.ts b/test/nodes-store.test.ts index 88b084f2..7bf30192 100644 --- a/test/nodes-store.test.ts +++ b/test/nodes-store.test.ts @@ -11,9 +11,15 @@ import { afterAll, afterEach, describe, expect, it } from "vitest"; import { EncryptedStore, UnencryptedStore } from "../src/encryption/encrypted-store.js"; import { KEY_BYTES, LocalKeyProvider } from "../src/encryption/keys.js"; import { nodeStore, type NodeInfo, type NodeRow, type Store } from "../src/storage/store.js"; -import { available, closeAdmins, dropDatabases, TEST_DATABASES, testStorage } from "./databases.js"; -import { cleanUp, makeProject } from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; +import { + available, + closeAdmins, + dropDatabases, + TEST_DATABASES, + testStorage, +} from "./_helpers/databases.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; const stores: Store[] = []; diff --git a/test/nodes.test.ts b/test/nodes.test.ts index 1cff405b..5ed21f1f 100644 --- a/test/nodes.test.ts +++ b/test/nodes.test.ts @@ -29,7 +29,7 @@ import type { NodeState, NodeStore, } from "../src/storage/store.js"; -import { cleanUp, makeProject } from "./helpers.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; afterEach(async () => { vi.restoreAllMocks(); diff --git a/test/object-store-config.test.ts b/test/object-store-config.test.ts index 7da7d3c5..00d466ab 100644 --- a/test/object-store-config.test.ts +++ b/test/object-store-config.test.ts @@ -10,7 +10,7 @@ import { ObjectDestination, ObjectSource } from "../src/connectors/object-store. import { S3Bucket } from "../src/connectors/s3.js"; import { connectorsFor } from "../src/engine/engine.js"; import { secretUses } from "../src/secrets/sources.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; // The channel keys source.file.s3, source.file.azblob, destinations[].file.s3 and // destinations[].file.azblob: what the schema takes and refuses, what they resolve to, and the diff --git a/test/object-store.test.ts b/test/object-store.test.ts index 5b9466d0..bb34561e 100644 --- a/test/object-store.test.ts +++ b/test/object-store.test.ts @@ -14,12 +14,12 @@ import { type ReceiveOptions, } from "../src/connectors/types.js"; import { markCopiesBodies } from "../src/storage/ownership.js"; -import { FakeObjectStore } from "./fake-object-store.js"; +import { FakeObjectStore } from "./_helpers/fake-object-store.js"; -// The object store source and destination over a store held in memory (test/fake-object-store.ts), -// which keeps S3's and Azure Blob's rules: a new entity tag on each write, and conditional writes, -// reads and deletes checked against it. The same source runs against LocalStack and Azurite in -// test/object-store-server.test.ts. +// The object store source and destination over a store held in memory +// (test/_helpers/fake-object-store.ts), which keeps S3's and Azure Blob's rules: a new entity tag +// on each write, and conditional writes, reads and deletes checked against it. The same source runs +// against LocalStack and Azurite in test/object-store-server.test.ts. /** A sink that stores each message once by its idempotency key, as the engine's store does. */ function store() { diff --git a/test/one-message.test.ts b/test/one-message.test.ts index 5477cb80..3934e870 100644 --- a/test/one-message.test.ts +++ b/test/one-message.test.ts @@ -15,7 +15,7 @@ import { loadProject } from "../src/config/load.js"; import { holdsSecondMessage, readHeader } from "../src/connectors/mllp.js"; import { Engine } from "../src/engine/engine.js"; import { decode } from "../src/engine/worker-entry.js"; -import { TEST_DATABASES, testStorage } from "./databases.js"; +import { TEST_DATABASES, testStorage } from "./_helpers/databases.js"; import { ADT_A01, ADT_A08, @@ -26,7 +26,7 @@ import { joinedResults, SECOND_HEADER_BEHIND, SECOND_HEADER_JOINED, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/operator-edges.test.ts b/test/operator-edges.test.ts index fd3ab7e9..ec481da5 100644 --- a/test/operator-edges.test.ts +++ b/test/operator-edges.test.ts @@ -19,8 +19,8 @@ import { type OperatorContext, } from "../src/operator/commands.js"; import { Store, type MessageStore, type RequeueResult } from "../src/storage/store.js"; -import { ADT_A01, cleanUp, LAB_TRANSFORM, makeProject } from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; +import { ADT_A01, cleanUp, LAB_TRANSFORM, makeProject } from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; const stores: Store[] = []; afterEach(async () => { diff --git a/test/operator.test.ts b/test/operator.test.ts index f786857e..d1fcaf27 100644 --- a/test/operator.test.ts +++ b/test/operator.test.ts @@ -34,7 +34,7 @@ import { TEST_DATABASES, testStorage, type TestDatabase, -} from "./databases.js"; +} from "./_helpers/databases.js"; import { ADT_A01, ADT_A08, @@ -45,7 +45,7 @@ import { LAB_TRANSFORM, makeProject, type LogEvent, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; const stores: Store[] = []; const engines: Engine[] = []; diff --git a/test/output-equivalence.test.ts b/test/output-equivalence.test.ts index c66a43f2..03ab4a4e 100644 --- a/test/output-equivalence.test.ts +++ b/test/output-equivalence.test.ts @@ -42,7 +42,7 @@ import { type WorkerFormat, } from "../src/engine/worker-entry.js"; import { Store } from "../src/storage/store.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; interface CorpusEntry { readonly id: string; diff --git a/test/ownership.test.ts b/test/ownership.test.ts index 757235e6..3bb19ecd 100644 --- a/test/ownership.test.ts +++ b/test/ownership.test.ts @@ -14,8 +14,8 @@ import { Engine } from "../src/engine/engine.js"; import { transferable } from "../src/engine/worker-entry.js"; import { copiesBodies, markCopiesBodies, ownsBuffer, release } from "../src/storage/ownership.js"; import { Store } from "../src/storage/store.js"; -import { captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; -import { MemoryStore } from "./memory-store.js"; +import { captureLogger, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; +import { MemoryStore } from "./_helpers/memory-store.js"; afterEach(cleanUp); diff --git a/test/poll-schedule.test.ts b/test/poll-schedule.test.ts index 8ffa062b..0064d371 100644 --- a/test/poll-schedule.test.ts +++ b/test/poll-schedule.test.ts @@ -13,7 +13,7 @@ import { } from "../src/config/schema.js"; import { deliveryDeadlineMs, LIVE_GRACE_MS, livenessBoundMs } from "../src/engine/engine.js"; import { nextPollAt, pollOf } from "../src/engine/schedule.js"; -import { cleanUp, makeProject } from "./helpers.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/probe-codeless.test.ts b/test/probe-codeless.test.ts index e8bcd591..68c60bd6 100644 --- a/test/probe-codeless.test.ts +++ b/test/probe-codeless.test.ts @@ -8,7 +8,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { EXIT, run } from "../src/cli.js"; import { generateKey } from "../src/encryption/keys.js"; import { askProbe } from "../src/engine/probes.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; vi.mock("node:http", async (importOriginal) => { const actual = await importOriginal(); diff --git a/test/probes.test.ts b/test/probes.test.ts index 4df3c703..2bad3531 100644 --- a/test/probes.test.ts +++ b/test/probes.test.ts @@ -24,7 +24,7 @@ import { } from "../src/engine/probes.js"; import { migrations, Store, type MessageStore } from "../src/storage/store.js"; import { VERSION } from "../src/version.js"; -import { MEMORY_STORE_FILE } from "./extension-helpers.js"; +import { MEMORY_STORE_FILE } from "./_helpers/extension-helpers.js"; import { ADT_A01, captureLogger, @@ -33,8 +33,8 @@ import { dropFileWhileRunning, makeProject, type LogEvent, -} from "./helpers.js"; -import { CLOSED_PORT, onPickedPorts, orTaken, send } from "./net-helpers.js"; +} from "./_helpers/helpers.js"; +import { CLOSED_PORT, onPickedPorts, orTaken, send } from "./_helpers/net-helpers.js"; const closers: (() => Promise)[] = []; afterEach(async () => { @@ -43,7 +43,7 @@ afterEach(async () => { await cleanUp(); }); -const LEASED_STORE_FILE = join(import.meta.dirname, "lease-memory-store.ts"); +const LEASED_STORE_FILE = join(import.meta.dirname, "_helpers", "lease-memory-store.ts"); beforeEach(async () => { const leased = (await import(pathToFileURL(LEASED_STORE_FILE).href)) as { leaseRows: Map; diff --git a/test/receive-race.test.ts b/test/receive-race.test.ts index f72a68c6..217c2033 100644 --- a/test/receive-race.test.ts +++ b/test/receive-race.test.ts @@ -33,10 +33,10 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { cleanUp, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; -const CHILD = join(import.meta.dirname, "receive-keys.ts"); +const CHILD = join(import.meta.dirname, "_helpers", "receive-keys.ts"); const stores: Store[] = []; const connections: Kysely[] = []; diff --git a/test/requeue-race.test.ts b/test/requeue-race.test.ts index 783d79d0..8437d9d3 100644 --- a/test/requeue-race.test.ts +++ b/test/requeue-race.test.ts @@ -37,8 +37,8 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; const BIN = join(import.meta.dirname, "../src/bin/pathways.ts"); diff --git a/test/retention-archive.test.ts b/test/retention-archive.test.ts index ad1fe550..0f2edcd5 100644 --- a/test/retention-archive.test.ts +++ b/test/retention-archive.test.ts @@ -26,8 +26,14 @@ import { Engine } from "../src/engine/engine.js"; import { runRetention, type RetentionOptions } from "../src/operator/retention.js"; import { dialectFor } from "../src/storage/dialects.js"; import type { MessageStore, RetentionStore } from "../src/storage/store.js"; -import { available, closeAdmins, dropDatabases, TEST_DATABASES, testStorage } from "./databases.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { + available, + closeAdmins, + dropDatabases, + TEST_DATABASES, + testStorage, +} from "./_helpers/databases.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; const DAY = 86_400_000; const closers: (() => Promise)[] = []; diff --git a/test/retry-settings.test.ts b/test/retry-settings.test.ts index de661139..4289784f 100644 --- a/test/retry-settings.test.ts +++ b/test/retry-settings.test.ts @@ -20,9 +20,14 @@ import { import { replayMessages } from "../src/operator/actions.js"; import { AuditLog } from "../src/operator/audit.js"; import { Store, type MessageStore } from "../src/storage/store.js"; -import { freshBench, LIST_DESTINATION, POLL_SOURCE, RECORD_HOOK } from "./extension-helpers.js"; -import { captureLogger, cleanUp, makeProject, type LogEvent } from "./helpers.js"; -import { receiver, type Receiver } from "./net-helpers.js"; +import { + freshBench, + LIST_DESTINATION, + POLL_SOURCE, + RECORD_HOOK, +} from "./_helpers/extension-helpers.js"; +import { captureLogger, cleanUp, makeProject, type LogEvent } from "./_helpers/helpers.js"; +import { receiver, type Receiver } from "./_helpers/net-helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/run-tests.test.ts b/test/run-tests.test.ts index 691c421e..12cc6789 100644 --- a/test/run-tests.test.ts +++ b/test/run-tests.test.ts @@ -26,7 +26,7 @@ import { LAB_TRANSFORM, makeProject, X12_270, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/safe-to-log-docs.test.ts b/test/safe-to-log-docs.test.ts index 36d10d4b..ab55243d 100644 --- a/test/safe-to-log-docs.test.ts +++ b/test/safe-to-log-docs.test.ts @@ -12,8 +12,8 @@ import { Engine } from "../src/engine/engine.js"; import { scriptLogLine } from "../src/engine/worker-entry.js"; import { openStore } from "../src/storage/open.js"; import { Store } from "../src/storage/store.js"; -import { fences } from "./docs-helpers.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; +import { fences } from "./_helpers/docs-helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/schema-steps.test.ts b/test/schema-steps.test.ts index d03e30df..4c5e1903 100644 --- a/test/schema-steps.test.ts +++ b/test/schema-steps.test.ts @@ -27,8 +27,8 @@ import { TEST_DATABASES, testStorage, type TestDatabase, -} from "./databases.js"; -import { cleanUp, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; const open: Kysely[] = []; diff --git a/test/schema-versions.test.ts b/test/schema-versions.test.ts index d8a06d09..2f332dae 100644 --- a/test/schema-versions.test.ts +++ b/test/schema-versions.test.ts @@ -19,8 +19,8 @@ import { testStorage, type TestDatabase, type TestStorage, -} from "./databases.js"; -import { cleanUp, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; const open: Kysely[] = []; const stores: Store[] = []; diff --git a/test/scripts/phi-scan.test.ts b/test/scripts/phi-scan.test.ts index 13fcb534..b82e07e6 100644 --- a/test/scripts/phi-scan.test.ts +++ b/test/scripts/phi-scan.test.ts @@ -342,7 +342,7 @@ describe("phi-scan fields: each format's identifying fields are caught", () => { describe("phi-scan fields: the allow-list declares synthetic tokens, file by file content", () => { it("clears the test patient in every format, and only because the allow-list declares it", () => { - const helpers = readFileSync(join(REPO_ROOT, "test", "helpers.ts"), "utf8"); + const helpers = readFileSync(join(REPO_ROOT, "test", "_helpers", "helpers.ts"), "utf8"); const undeclared = detect(helpers, EMPTY).fields; // The same file, read with nothing declared: every format's fields are found in it. for (const field of [ diff --git a/test/secrets-property.test.ts b/test/secrets-property.test.ts index 47b5f37b..2f84350f 100644 --- a/test/secrets-property.test.ts +++ b/test/secrets-property.test.ts @@ -12,9 +12,9 @@ import { fakeSecretProvider } from "../src/index.js"; import { resolveSecrets, Secrets } from "../src/secrets/resolve.js"; import { dialectFor } from "../src/storage/dialects.js"; import { configuredName } from "../src/env.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; -import { serverStorage } from "./databases.js"; -import { built } from "./secret-vault.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; +import { serverStorage } from "./_helpers/databases.js"; +import { built } from "./_helpers/secret-vault.js"; /** * No secret's value reaches a thrown error or a log line, whatever it holds: a property test over @@ -140,7 +140,7 @@ describe("no secret value in any error", () => { describe("no secret value in any error or log line from a provider", () => { let project: ProjectConfig; beforeAll(async () => { - const vault = fileURLToPath(new URL("./secret-vault.ts", import.meta.url)); + const vault = fileURLToPath(new URL("./_helpers/secret-vault.ts", import.meta.url)); const root = await makeProject({ "pathways.yaml": [ "encryption:", diff --git a/test/secrets.test.ts b/test/secrets.test.ts index ae8daf06..598c0770 100644 --- a/test/secrets.test.ts +++ b/test/secrets.test.ts @@ -28,7 +28,7 @@ import { resolveSecrets, Secrets, secretsOf } from "../src/secrets/resolve.js"; import { secretUses } from "../src/secrets/sources.js"; import { dialectFor } from "../src/storage/dialects.js"; import { configuredName } from "../src/env.js"; -import { serverStorage } from "./databases.js"; +import { serverStorage } from "./_helpers/databases.js"; import { ADT_A01, captureLogger, @@ -37,11 +37,11 @@ import { LAB_TRANSFORM, makeProject, type LogEvent, -} from "./helpers.js"; -import { receiver, status, type Receiver } from "./net-helpers.js"; -import { built } from "./secret-vault.js"; +} from "./_helpers/helpers.js"; +import { receiver, status, type Receiver } from "./_helpers/net-helpers.js"; +import { built } from "./_helpers/secret-vault.js"; -const VAULT = fileURLToPath(new URL("./secret-vault.ts", import.meta.url)); +const VAULT = fileURLToPath(new URL("./_helpers/secret-vault.ts", import.meta.url)); const TOKEN = "synthetic-vault-token-0123456789"; const receivers: Receiver[] = []; diff --git a/test/send-marker.test.ts b/test/send-marker.test.ts index c3a9fe62..b6f7bd13 100644 --- a/test/send-marker.test.ts +++ b/test/send-marker.test.ts @@ -25,9 +25,9 @@ import { freshDatabase, TEST_DATABASES, type TestDatabase, -} from "./databases.js"; -import { freshBench, RECORD_HOOK } from "./extension-helpers.js"; -import { captureLogger, cleanUp, makeProject, type LogEvent } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { freshBench, RECORD_HOOK } from "./_helpers/extension-helpers.js"; +import { captureLogger, cleanUp, makeProject, type LogEvent } from "./_helpers/helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/settled.test.ts b/test/settled.test.ts index 32c07452..4e1ae341 100644 --- a/test/settled.test.ts +++ b/test/settled.test.ts @@ -23,8 +23,8 @@ import { TEST_DATABASES, testStorage, type TestDatabase, -} from "./databases.js"; -import { captureLogger, cleanUp, makeProject, type LogEvent } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { captureLogger, cleanUp, makeProject, type LogEvent } from "./_helpers/helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/sftp-config.test.ts b/test/sftp-config.test.ts index f7477383..fa92c447 100644 --- a/test/sftp-config.test.ts +++ b/test/sftp-config.test.ts @@ -10,8 +10,8 @@ import { fingerprint } from "../src/connectors/known-hosts.js"; import type { MessageSink } from "../src/connectors/types.js"; import { connectorsFor } from "../src/engine/engine.js"; import { secretUses } from "../src/secrets/sources.js"; -import { fakeServer, fakeSsh2, resetFakeServer } from "./fake-ssh2.js"; -import { captureLogger, cleanUp, makeProject, usePlatform } from "./helpers.js"; +import { fakeServer, fakeSsh2, resetFakeServer } from "./_helpers/fake-ssh2.js"; +import { captureLogger, cleanUp, makeProject, usePlatform } from "./_helpers/helpers.js"; vi.mock("ssh2", () => fakeSsh2); diff --git a/test/sftp-crash.test.ts b/test/sftp-crash.test.ts index c8d307eb..fd880350 100644 --- a/test/sftp-crash.test.ts +++ b/test/sftp-crash.test.ts @@ -5,7 +5,7 @@ // it with SIGKILL. After a restart each file is stored once and delivered once to each // destination, none is left on the server, and a clean restart after that sends nothing again. // -// It runs where PATHWAYS_TEST_SSHD names the sshd binary (test/sshd.ts), as +// It runs where PATHWAYS_TEST_SSHD names the sshd binary (test/_helpers/sshd.ts), as // .github/workflows/sftp.yml sets it, on SQLite: the crash tests in test/fault-points.test.ts run // the same steps on a local folder, and on each database server. import { spawn } from "node:child_process"; @@ -23,9 +23,9 @@ import { type FaultPoint, } from "../src/fault-points.js"; import { Store } from "../src/storage/store.js"; -import { leaseLapsed } from "./databases.js"; -import { cleanUp, dropFile, makeProject } from "./helpers.js"; -import { SSHD, type Sshd, startSshd, stopAllSshd } from "./sshd.js"; +import { leaseLapsed } from "./_helpers/databases.js"; +import { cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; +import { SSHD, type Sshd, startSshd, stopAllSshd } from "./_helpers/sshd.js"; const BIN = join(import.meta.dirname, "../src/bin/pathways.ts"); diff --git a/test/sftp-server.test.ts b/test/sftp-server.test.ts index ce0fe026..d54c2996 100644 --- a/test/sftp-server.test.ts +++ b/test/sftp-server.test.ts @@ -10,8 +10,8 @@ import { CLAIMED_DIR, FileDestination, FileSource } from "../src/connectors/file import { fingerprint, KnownHosts } from "../src/connectors/known-hosts.js"; import { SftpLocation, type SftpOptions } from "../src/connectors/sftp.js"; import type { MessageSink, ReceiveOptions } from "../src/connectors/types.js"; -import { cleanUp } from "./helpers.js"; -import { ed25519KeyPair } from "./ssh-keys.js"; +import { cleanUp } from "./_helpers/helpers.js"; +import { ed25519KeyPair } from "./_helpers/ssh-keys.js"; import { listening, runSshd, @@ -21,10 +21,10 @@ import { startSshd, stopAllSshd, stopSshd, -} from "./sshd.js"; +} from "./_helpers/sshd.js"; // The SFTP location against OpenSSH's own server, started here on the loopback as this user, with -// throwaway keys made for the run and synthetic files only (test/sshd.ts). It runs where +// throwaway keys made for the run and synthetic files only (test/_helpers/sshd.ts). It runs where // PATHWAYS_TEST_SSHD names the sshd binary: .github/workflows/sftp.yml sets it. Elsewhere it is // skipped, and test/sftp.test.ts runs the same location against a stand-in for the SSH package. diff --git a/test/sftp.test.ts b/test/sftp.test.ts index a80cd8b4..33941faa 100644 --- a/test/sftp.test.ts +++ b/test/sftp.test.ts @@ -8,8 +8,8 @@ import { CLAIMED_DIR, FileDestination, FileSource } from "../src/connectors/file import { fingerprint, HostKeyError, KnownHosts } from "../src/connectors/known-hosts.js"; import { SftpLocation, type SftpOptions } from "../src/connectors/sftp.js"; import type { MessageSink, ReceiveOptions } from "../src/connectors/types.js"; -import { fakeServer, fakeSsh2, resetFakeServer, UNREADABLE_KEY } from "./fake-ssh2.js"; -import { cleanUp, makeProject } from "./helpers.js"; +import { fakeServer, fakeSsh2, resetFakeServer, UNREADABLE_KEY } from "./_helpers/fake-ssh2.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; vi.mock("ssh2", () => fakeSsh2); diff --git a/test/smtp-config.test.ts b/test/smtp-config.test.ts index 2444f0cd..1ec649cb 100644 --- a/test/smtp-config.test.ts +++ b/test/smtp-config.test.ts @@ -8,10 +8,10 @@ import { SmtpDestination } from "../src/connectors/smtp.js"; import { connectorsFor, Engine } from "../src/engine/engine.js"; import { secretUses } from "../src/secrets/sources.js"; import { Store } from "../src/storage/store.js"; -import { ADT_A01, captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; -import { OPENSSL } from "./mllp-helpers.js"; -import { makeCertificates, removeCertificates, type Certificates } from "./net-helpers.js"; -import { startPeer, type Peer, type PeerOptions } from "./smtp-peer.js"; +import { ADT_A01, captureLogger, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; +import { OPENSSL } from "./_helpers/mllp-helpers.js"; +import { makeCertificates, removeCertificates, type Certificates } from "./_helpers/net-helpers.js"; +import { startPeer, type Peer, type PeerOptions } from "./_helpers/smtp-peer.js"; const peers: Peer[] = []; const engines: Engine[] = []; diff --git a/test/smtp.test.ts b/test/smtp.test.ts index eedca8b2..b7ab9222 100644 --- a/test/smtp.test.ts +++ b/test/smtp.test.ts @@ -19,15 +19,15 @@ import { } from "../src/connectors/smtp.js"; import { renderTemplate, unknownPlaceholders } from "../src/connectors/smtp-template.js"; import { DeliveryRejected, type OutgoingMessage } from "../src/connectors/types.js"; -import { ADT_A01 } from "./helpers.js"; -import { OPENSSL, TLS_TESTS } from "./mllp-helpers.js"; +import { ADT_A01 } from "./_helpers/helpers.js"; +import { OPENSSL, TLS_TESTS } from "./_helpers/mllp-helpers.js"; import { CLOSED_PORT, makeCertificates, removeCertificates, type Certificates, -} from "./net-helpers.js"; -import { startPeer, type Peer, type PeerOptions } from "./smtp-peer.js"; +} from "./_helpers/net-helpers.js"; +import { startPeer, type Peer, type PeerOptions } from "./_helpers/smtp-peer.js"; const peers: Peer[] = []; diff --git a/test/sqlite-statements.test.ts b/test/sqlite-statements.test.ts index 1d2d8a0c..a26510a3 100644 --- a/test/sqlite-statements.test.ts +++ b/test/sqlite-statements.test.ts @@ -9,7 +9,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { cachedStatements } from "../src/storage/dialects.js"; import { Store } from "../src/storage/store.js"; -import { cleanUp, makeProject } from "./helpers.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; afterEach(async () => { vi.restoreAllMocks(); diff --git a/test/ssh-keys.test.ts b/test/ssh-keys.test.ts index f1d29064..6c527f5d 100644 --- a/test/ssh-keys.test.ts +++ b/test/ssh-keys.test.ts @@ -6,12 +6,13 @@ import { join } from "node:path"; import { utils } from "ssh2"; import { afterAll, describe, expect, it } from "vitest"; -import { cleanUp, makeProject } from "./helpers.js"; -import { ed25519KeyPair, type SshKeyPair } from "./ssh-keys.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; +import { ed25519KeyPair, type SshKeyPair } from "./_helpers/ssh-keys.js"; -// The throwaway keys the SFTP suites start OpenSSH's server with (test/ssh-keys.ts). Each must read -// back whole in the SSH package and in ssh-keygen, including a key whose public key starts with a -// zero byte: the package's own generator cuts that byte off, so about one key in 256 was unreadable. +// The throwaway keys the SFTP suites start OpenSSH's server with (test/_helpers/ssh-keys.ts). Each +// must read back whole in the SSH package and in ssh-keygen, including a key whose public key +// starts with a zero byte: the package's own generator cuts that byte off, so about one key in 256 +// was unreadable. /** The key blob of an OpenSSH public key line. */ const blobOf = (line: string): Buffer => Buffer.from(String(line.split(" ")[1]), "base64"); diff --git a/test/store-edges.test.ts b/test/store-edges.test.ts index b22b2825..76b72667 100644 --- a/test/store-edges.test.ts +++ b/test/store-edges.test.ts @@ -7,7 +7,7 @@ import { afterEach, describe, expect, it } from "vitest"; import SqliteDatabase from "better-sqlite3"; import { Store } from "../src/storage/store.js"; -import { cleanUp, makeProject } from "./helpers.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; const stores: Store[] = []; afterEach(async () => { diff --git a/test/store-operator.test.ts b/test/store-operator.test.ts index 92b5afa4..5eff0db4 100644 --- a/test/store-operator.test.ts +++ b/test/store-operator.test.ts @@ -19,8 +19,8 @@ import { freshDatabase, TEST_DATABASES, type TestDatabase, -} from "./databases.js"; -import { cleanUp, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; const stores: Store[] = []; diff --git a/test/store-servers.test.ts b/test/store-servers.test.ts index 47ed5385..c6fd74c4 100644 --- a/test/store-servers.test.ts +++ b/test/store-servers.test.ts @@ -15,7 +15,7 @@ import { serverStorage, URL_ENV, type TestDatabase, -} from "./databases.js"; +} from "./_helpers/databases.js"; import { ADT_A01, ADT_A08, @@ -24,7 +24,7 @@ import { dropFile, LAB_TRANSFORM, makeProject, -} from "./helpers.js"; +} from "./_helpers/helpers.js"; afterEach(async () => { await dropDatabases(); diff --git a/test/store-sql-mode.test.ts b/test/store-sql-mode.test.ts index 5374d5b0..e67f2b0d 100644 --- a/test/store-sql-mode.test.ts +++ b/test/store-sql-mode.test.ts @@ -11,7 +11,7 @@ import { freshDatabase, SERVER_DATABASES, type TestDatabase, -} from "./databases.js"; +} from "./_helpers/databases.js"; afterEach(dropDatabases); afterAll(closeAdmins); diff --git a/test/store.test.ts b/test/store.test.ts index 2b78fc5a..e6550eda 100644 --- a/test/store.test.ts +++ b/test/store.test.ts @@ -12,8 +12,8 @@ import { freshDatabase, TEST_DATABASES, type TestDatabase, -} from "./databases.js"; -import { cleanUp, makeProject } from "./helpers.js"; +} from "./_helpers/databases.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; const stores: Store[] = []; diff --git a/test/tcp-config.test.ts b/test/tcp-config.test.ts index 8d66fef4..cb1c0b15 100644 --- a/test/tcp-config.test.ts +++ b/test/tcp-config.test.ts @@ -18,8 +18,8 @@ import { TcpDestination, TcpSource } from "../src/connectors/tcp.js"; import { connectorsFor, deliveryDeadlineMs, Engine } from "../src/engine/engine.js"; import { ExtensionLoadError } from "../src/extensions/load.js"; import { Store } from "../src/storage/store.js"; -import { captureLogger, cleanUp, makeProject } from "./helpers.js"; -import { CLOSED_PORT, onPickedPorts, sourceListening } from "./net-helpers.js"; +import { captureLogger, cleanUp, makeProject } from "./_helpers/helpers.js"; +import { CLOSED_PORT, onPickedPorts, sourceListening } from "./_helpers/net-helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/tcp-destination.test.ts b/test/tcp-destination.test.ts index b65fee53..e90dc278 100644 --- a/test/tcp-destination.test.ts +++ b/test/tcp-destination.test.ts @@ -17,13 +17,13 @@ import { type TcpReply, } from "../src/connectors/tcp.js"; import { DeliveryRejected } from "../src/connectors/types.js"; -import { OPENSSL, TLS_TESTS } from "./mllp-helpers.js"; +import { OPENSSL, TLS_TESTS } from "./_helpers/mllp-helpers.js"; import { CLOSED_PORT, makeCertificates, removeCertificates, type Certificates, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; const hex = (text: string): Buffer => Buffer.from(text, "hex"); const text = (value: string): Buffer => Buffer.from(value, "latin1"); diff --git a/test/tcp-source.test.ts b/test/tcp-source.test.ts index c9477dfd..8e58f877 100644 --- a/test/tcp-source.test.ts +++ b/test/tcp-source.test.ts @@ -12,8 +12,8 @@ import { type TcpSourceOptions, } from "../src/connectors/tcp.js"; import type { MessageSink, ReceiveOptions } from "../src/connectors/types.js"; -import { OPENSSL, TLS_TESTS } from "./mllp-helpers.js"; -import { makeCertificates, removeCertificates, type Certificates } from "./net-helpers.js"; +import { OPENSSL, TLS_TESTS } from "./_helpers/mllp-helpers.js"; +import { makeCertificates, removeCertificates, type Certificates } from "./_helpers/net-helpers.js"; const sources: TcpSource[] = []; diff --git a/test/transform-context.test.ts b/test/transform-context.test.ts index a4f374f1..fc09608e 100644 --- a/test/transform-context.test.ts +++ b/test/transform-context.test.ts @@ -46,8 +46,13 @@ import { AuditLog } from "../src/operator/audit.js"; import { replayMessages } from "../src/operator/actions.js"; import { Store } from "../src/storage/store.js"; import { runChannelTests } from "../src/testing/run-tests.js"; -import { ADT_A01, captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; -import { makeCertificates, removeCertificates, send, type Certificates } from "./net-helpers.js"; +import { ADT_A01, captureLogger, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; +import { + makeCertificates, + removeCertificates, + send, + type Certificates, +} from "./_helpers/net-helpers.js"; // A project names its configuration's keys by declaration merging, as the docs show. declare module "@cosyte/pathways" { diff --git a/test/transform-types.test.ts b/test/transform-types.test.ts index 38926eaa..ded81ab3 100644 --- a/test/transform-types.test.ts +++ b/test/transform-types.test.ts @@ -17,7 +17,7 @@ import type { TransformOutput, X12Interchange, } from "../src/index.js"; -import { ADT_A01, ADT_A08, CCDA_DOCUMENT, FHIR_PATIENT, X12_270 } from "./helpers.js"; +import { ADT_A01, ADT_A08, CCDA_DOCUMENT, FHIR_PATIENT, X12_270 } from "./_helpers/helpers.js"; const bytes = (text: string): Uint8Array => new TextEncoder().encode(text); const text = (body: Uint8Array | undefined): string => new TextDecoder().decode(body); diff --git a/test/verify.test.ts b/test/verify.test.ts index b59c8b38..31521bb9 100644 --- a/test/verify.test.ts +++ b/test/verify.test.ts @@ -20,7 +20,14 @@ import { jsonDifference, locate, } from "../src/operator/difference.js"; -import { ADT_A01, ADT_A08, captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; +import { + ADT_A01, + ADT_A08, + captureLogger, + cleanUp, + dropFile, + makeProject, +} from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/webhook.test.ts b/test/webhook.test.ts index 3781f23b..5aa60ab5 100644 --- a/test/webhook.test.ts +++ b/test/webhook.test.ts @@ -3,9 +3,14 @@ import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; import { ConfigError, loadProject } from "../src/config/load.js"; import { Engine } from "../src/engine/engine.js"; import { Store } from "../src/storage/store.js"; -import { eventually, freshBench, LIST_DESTINATION, POLL_SOURCE } from "./extension-helpers.js"; -import { captureLogger, cleanUp, makeProject, type LogEvent } from "./helpers.js"; -import { TLS_TESTS } from "./mllp-helpers.js"; +import { + eventually, + freshBench, + LIST_DESTINATION, + POLL_SOURCE, +} from "./_helpers/extension-helpers.js"; +import { captureLogger, cleanUp, makeProject, type LogEvent } from "./_helpers/helpers.js"; +import { TLS_TESTS } from "./_helpers/mllp-helpers.js"; import { makeCertificates, receiver, @@ -13,7 +18,7 @@ import { status, type Certificates, type Receiver, -} from "./net-helpers.js"; +} from "./_helpers/net-helpers.js"; const engines: Engine[] = []; const stores: Store[] = []; diff --git a/test/worker-entry.test.ts b/test/worker-entry.test.ts index 8e7458b4..b3877a8d 100644 --- a/test/worker-entry.test.ts +++ b/test/worker-entry.test.ts @@ -27,7 +27,14 @@ import { type TransformFunction, type WorkerFormat, } from "../src/engine/worker-entry.js"; -import { ADT_A01, CCDA_DOCUMENT, cleanUp, FHIR_PATIENT, makeProject, X12_270 } from "./helpers.js"; +import { + ADT_A01, + CCDA_DOCUMENT, + cleanUp, + FHIR_PATIENT, + makeProject, + X12_270, +} from "./_helpers/helpers.js"; afterEach(cleanUp); diff --git a/test/worker-memory.test.ts b/test/worker-memory.test.ts index 1fd151b9..792a89e8 100644 --- a/test/worker-memory.test.ts +++ b/test/worker-memory.test.ts @@ -15,7 +15,7 @@ import { afterEach, describe, expect, it } from "vitest"; import * as S from "../bench/shapes.mjs"; import { DEFAULT_SETTINGS } from "../src/config/schema.js"; import { ChannelWorker } from "../src/engine/channel-worker.js"; -import { cleanUp, makeProject } from "./helpers.js"; +import { cleanUp, makeProject } from "./_helpers/helpers.js"; const workers: ChannelWorker[] = []; diff --git a/test/xml-format.test.ts b/test/xml-format.test.ts index ff00de0b..7831a819 100644 --- a/test/xml-format.test.ts +++ b/test/xml-format.test.ts @@ -15,8 +15,8 @@ import { XML_DEFAULTS, type XmlSettings, } from "../src/engine/worker-entry.js"; -import { TEST_DATABASES, testStorage } from "./databases.js"; -import { captureLogger, cleanUp, dropFile, makeProject } from "./helpers.js"; +import { TEST_DATABASES, testStorage } from "./_helpers/databases.js"; +import { captureLogger, cleanUp, dropFile, makeProject } from "./_helpers/helpers.js"; // Every value below is synthetic: ids, codes and names that are plainly fake. From 80fc59fb303a80253f3fe3043b8e1444cea19630 Mon Sep 17 00:00:00 2001 From: Noah Schatz Date: Sun, 29 Nov 2026 23:53:41 -0500 Subject: [PATCH 3/6] docs(readme): follow the shared package README layout The README takes the package name as its title, the four badges, and the sections Why this exists, Status, Install and Usage in order, with the link to docs.cosyte.com/pathways after Usage. Its Status names the release line (**The `0.0` line.**) where it named an exact version, which went stale with every release. test/readme.test.ts holds the README to the shared skeleton check in pnpm test, and check:readme and check:catalog run the same checks from the command line. The release-status test now requires the release line package.json is on and refuses an exact version named as the one on npm, and the version step's README sync rewrites the release line where it rewrote the version. --- .changeset/readme-skeleton.md | 5 + README.md | 203 +++++++++++++------------ package.json | 2 + scripts/next-release-sync.ts | 28 ++-- scripts/sync-next-release.ts | 6 +- test/readme.test.ts | 23 +++ test/release-status.test.ts | 93 ++++++++--- test/scripts/sync-next-release.test.ts | 63 ++++---- 8 files changed, 251 insertions(+), 172 deletions(-) create mode 100644 .changeset/readme-skeleton.md create mode 100644 test/readme.test.ts diff --git a/.changeset/readme-skeleton.md b/.changeset/readme-skeleton.md new file mode 100644 index 00000000..f57f671d --- /dev/null +++ b/.changeset/readme-skeleton.md @@ -0,0 +1,5 @@ +--- +"@cosyte/pathways": patch +--- + +The README now follows the layout every Cosyte package README shares: the package name as its title, four badges (npm version, CI, license, Node), and the sections Why this exists, Status, Install and Usage in that order, with a link to docs.cosyte.com/pathways. Its Status names the release line rather than an exact version. diff --git a/README.md b/README.md index 41d086c8..c0f17cfa 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,14 @@ -# Pathways +# @cosyte/pathways > A code-first healthcare integration engine for Node.js: channels in YAML, transforms in TypeScript. +[![npm version](https://img.shields.io/npm/v/@cosyte/pathways.svg)](https://www.npmjs.com/package/@cosyte/pathways) [![CI](https://img.shields.io/github/actions/workflow/status/cosyte/pathways/ci.yml?branch=main&label=CI)](https://github.com/cosyte/pathways/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/cosyte/pathways/blob/main/LICENSE) +[![Node](https://img.shields.io/badge/node-%3E%3D24.0.0-brightgreen.svg)](https://nodejs.org) A code-first healthcare integration engine for Node.js. Channels are YAML files in git, transforms are TypeScript functions, and both are tested like any other code. @@ -23,15 +25,15 @@ version is 0.0.x, and a release may still change a key or an API, which its chan ## Contents -- [Install](#install) -- [Quickstart](#quickstart) - [Why this exists](#why-this-exists) +- [Status](#status) - [What the latest release ships](#what-the-latest-release-ships) - [In the next release](#in-the-next-release) -- [Status](#status) +- [Install](#install) +- [Usage](#usage) +- [Documentation](#documentation) - [Build from source](#build-from-source) - [Layout](#layout) -- [Documentation](#documentation) - [Support](#support) - [Security](#security) - [Contributing](#contributing) @@ -39,72 +41,6 @@ version is 0.0.x, and a release may still change a key or an API, which its chan --- -## Install - -Pathways needs Node.js 24 or later. Start a new project with the starter, which lists the package in -its own `package.json`: - -```bash -npx @cosyte/pathways init my-project -cd my-project -npm install -``` - -Or add it to a project you have, as a development dependency so the project pins its version: - -```bash -npm install --save-dev @cosyte/pathways -npx pathways --version -``` - -SQLite works with no setup. For PostgreSQL, MySQL or MariaDB, or SQL Server, install that -database's driver in the project: -[Install Pathways](https://github.com/cosyte/pathways/blob/main/docs-content/installation.md) lists -them. - ---- - -## Quickstart - -The starter holds one channel, `adt-to-lab`: it reads HL7 v2 files from `data/adt-to-lab/in`, keeps -only admissions (`ADT^A01`), sets the receiving application to `LAB`, and writes them to -`data/adt-to-lab/out`. Its two test messages are synthetic. - -In the project `init` wrote, run the channel's tests, then start the engine: - -```bash -npm test -npm start -``` - -`npm test` runs `pathways test`, which sends each test message through the transform and compares -the output with the `.expected` file beside it. `npm start` runs the channel until you stop it. In a -second terminal, in the same folder, drop the test messages into the channel's inbox: - -```bash -mkdir -p data/adt-to-lab/in -cp channels/adt-to-lab/tests/a01.hl7 channels/adt-to-lab/tests/a08.hl7 data/adt-to-lab/in/ -``` - -Within a few seconds the admission is delivered to `data/adt-to-lab/out/1-1.hl7` and the update is -filtered out. Stop the engine with Ctrl+C, and `npx pathways status` counts one delivered. The -[quickstart](https://github.com/cosyte/pathways/blob/main/docs-content/quickstart.md) walks through -each step and what the engine logs. - -For the common shapes, start from an example in -[`examples/`](https://github.com/cosyte/pathways/tree/main/examples): a small project that runs on -synthetic messages, with its tests, which CI runs on every change. Each has a page: - -- [HL7 v2 over MLLP in, HTTP out](https://github.com/cosyte/pathways/blob/main/docs-content/example-mllp-to-http.md) -- [A file drop to SFTP](https://github.com/cosyte/pathways/blob/main/docs-content/example-file-to-sftp.md) -- [HL7 v2 to FHIR](https://github.com/cosyte/pathways/blob/main/docs-content/example-hl7-to-fhir.md) -- [Filter, then send to two destinations](https://github.com/cosyte/pathways/blob/main/docs-content/example-filter-and-route.md) -- [Replay after a failure](https://github.com/cosyte/pathways/blob/main/docs-content/example-replay-after-failure.md) -- [A veterinary lab result to FHIR](https://github.com/cosyte/pathways/blob/main/docs-content/example-vet-lab-to-fhir.md) -- [A veterinary lab result as v2 XML over HTTPS](https://github.com/cosyte/pathways/blob/main/docs-content/example-vet-lab-to-v2-xml.md) - ---- - ## Why this exists Pathways is for a developer who writes and runs integrations: someone who would rather review a @@ -118,9 +54,20 @@ one), and not a sandbox: a transform is your own trusted code. --- +## Status + +**The `0.0` line.** Early, and released on npm. Each release is published with provenance from this +repository's release workflow, with its signed image. Watch or star the repository to follow along. + +Pathways is an open engine, MIT licensed and free to self-host. We plan to offer hosted, managed +Pathways as well. Need an integration built, or hosted and run for you? See our +[integration services](https://cosyte.com/integration-services). + +--- + ## What the latest release ships -What follows is in 0.0.7, the version on npm: +What follows is in the latest release, the one on npm: - **Channels in git.** A channel is a YAML file that wires a source to its destinations. Its transform is a TypeScript file that receives the parsed message and returns what to send. @@ -246,52 +193,75 @@ These are on `main` and land in the next release: --- -## Status +## Install -Early, and released: 0.0.7 is on npm. Each release is published with provenance from this -repository's release workflow, with its signed image. Watch or star the repository to follow along. +Pathways needs Node.js 24 or later. Start a new project with the starter, which lists the package in +its own `package.json`: -Pathways is an open engine, MIT licensed and free to self-host. We plan to offer hosted, managed -Pathways as well. Need an integration built, or hosted and run for you? See our -[integration services](https://cosyte.com/integration-services). +```bash +npx @cosyte/pathways init my-project +cd my-project +npm install +``` + +Or add it to a project you have, as a development dependency so the project pins its version: + +```bash +npm install --save-dev @cosyte/pathways +npx pathways --version +``` + +SQLite works with no setup. For PostgreSQL, MySQL or MariaDB, or SQL Server, install that +database's driver in the project: +[Install Pathways](https://github.com/cosyte/pathways/blob/main/docs-content/installation.md) lists +them. --- -## Build from source +## Usage -To work on Pathways itself, or to run what is on `main` before it is released, build it from a -clone. It needs Node.js 24 or later and pnpm at the version `packageManager` in `package.json` -names: +The starter holds one channel, `adt-to-lab`: it reads HL7 v2 files from `data/adt-to-lab/in`, keeps +only admissions (`ADT^A01`), sets the receiving application to `LAB`, and writes them to +`data/adt-to-lab/out`. Its two test messages are synthetic. + +In the project `init` wrote, run the channel's tests, then start the engine: ```bash -git clone https://github.com/cosyte/pathways.git -cd pathways -pnpm install --frozen-lockfile -pnpm build -node dist/bin/pathways.mjs --version +npm test +npm start ``` -`node dist/bin/pathways.mjs` then stands in for `pathways` in every command the documentation shows. -`AGENTS.md` lists the checks to run before a pull request. +`npm test` runs `pathways test`, which sends each test message through the transform and compares +the output with the `.expected` file beside it. `npm start` runs the channel until you stop it. In a +second terminal, in the same folder, drop the test messages into the channel's inbox: ---- +```bash +mkdir -p data/adt-to-lab/in +cp channels/adt-to-lab/tests/a01.hl7 channels/adt-to-lab/tests/a08.hl7 data/adt-to-lab/in/ +``` -## Layout +Within a few seconds the admission is delivered to `data/adt-to-lab/out/1-1.hl7` and the update is +filtered out. Stop the engine with Ctrl+C, and `npx pathways status` counts one delivered. The +[quickstart](https://github.com/cosyte/pathways/blob/main/docs-content/quickstart.md) walks through +each step and what the engine logs. -- `src/`: the engine, its connectors, storage, encryption and the `pathways` command. -- `test/`: the test suites. -- `templates/starter/`: the starter project `pathways init` writes. -- `examples/`: example projects, each with its tests and a page in `docs-content/`. -- `examples/docker-compose/`: the engine under Docker Compose, beside PostgreSQL. -- `docs-content/`: the documentation pages. -- `bench/`: the benchmark suites. -- `scripts/`: the repository's own scripts. -- `Dockerfile`: the container image. +For the common shapes, start from an example in +[`examples/`](https://github.com/cosyte/pathways/tree/main/examples): a small project that runs on +synthetic messages, with its tests, which CI runs on every change. Each has a page: + +- [HL7 v2 over MLLP in, HTTP out](https://github.com/cosyte/pathways/blob/main/docs-content/example-mllp-to-http.md) +- [A file drop to SFTP](https://github.com/cosyte/pathways/blob/main/docs-content/example-file-to-sftp.md) +- [HL7 v2 to FHIR](https://github.com/cosyte/pathways/blob/main/docs-content/example-hl7-to-fhir.md) +- [Filter, then send to two destinations](https://github.com/cosyte/pathways/blob/main/docs-content/example-filter-and-route.md) +- [Replay after a failure](https://github.com/cosyte/pathways/blob/main/docs-content/example-replay-after-failure.md) +- [A veterinary lab result to FHIR](https://github.com/cosyte/pathways/blob/main/docs-content/example-vet-lab-to-fhir.md) +- [A veterinary lab result as v2 XML over HTTPS](https://github.com/cosyte/pathways/blob/main/docs-content/example-vet-lab-to-v2-xml.md) --- ## Documentation +The documentation is published at [docs.cosyte.com/pathways](https://docs.cosyte.com/pathways). The pages live in this repository's [`docs-content/`](https://github.com/cosyte/pathways/tree/main/docs-content). Start with these: @@ -312,6 +282,39 @@ The pages live in this repository's --- +## Build from source + +To work on Pathways itself, or to run what is on `main` before it is released, build it from a +clone. It needs Node.js 24 or later and pnpm at the version `packageManager` in `package.json` +names: + +```bash +git clone https://github.com/cosyte/pathways.git +cd pathways +pnpm install --frozen-lockfile +pnpm build +node dist/bin/pathways.mjs --version +``` + +`node dist/bin/pathways.mjs` then stands in for `pathways` in every command the documentation shows. +`AGENTS.md` lists the checks to run before a pull request. + +--- + +## Layout + +- `src/`: the engine, its connectors, storage, encryption and the `pathways` command. +- `test/`: the test suites. +- `templates/starter/`: the starter project `pathways init` writes. +- `examples/`: example projects, each with its tests and a page in `docs-content/`. +- `examples/docker-compose/`: the engine under Docker Compose, beside PostgreSQL. +- `docs-content/`: the documentation pages. +- `bench/`: the benchmark suites. +- `scripts/`: the repository's own scripts. +- `Dockerfile`: the container image. + +--- + ## Support Questions, bug reports and feature requests go on the diff --git a/package.json b/package.json index 3225835a..e43839e1 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,8 @@ "check:no-emdash": "cosyte-no-emdash", "check:no-internal-refs": "cosyte-internal-refs", "check:claude-card": "cosyte-claude-card", + "check:readme": "cosyte-readme", + "check:catalog": "cosyte-catalog", "check:process": "cosyte-process check", "lint": "cosyte-process lint", "lint:fix": "cosyte-process lint --fix", diff --git a/scripts/next-release-sync.ts b/scripts/next-release-sync.ts index 0f682f4e..f2e14f25 100644 --- a/scripts/next-release-sync.ts +++ b/scripts/next-release-sync.ts @@ -1,8 +1,8 @@ /** * Keep the README's "In the next release" section to what no release has shipped yet, move what a - * release shipped up into "What the latest release ships", and name the new version as the one on - * npm. npm shows the README of the version it serves, so the Version Packages commit has to say what - * that version holds. + * release shipped up into "What the latest release ships", and name the new version's release line + * in the Status section. npm shows the README of the version it serves, so the Version Packages + * commit has to say what that version holds. * * Each next-release bullet names the changesets it stands for in an HTML comment, * ``. The release's `version` script runs `changeset version`, which @@ -22,8 +22,9 @@ * - While a bullet stays, each version in the section's lead text becomes the new one ("not in * 0.0.3" reads "not in 0.0.4"). Once none stays, the section and its Contents line go: an empty * section says nothing a reader can use, and the next change that needs a bullet adds it back. - * - Every version the README names as the one on npm ("0.0.3, the version on npm", "0.0.3 is on - * npm") becomes the new one, with or without a next-release section. + * - The release-line marker (**The `0.0` line.**) names the new version's major and minor, with or + * without a next-release section. The README names no exact version as the one on npm: an exact + * version is stale after the next release. * - A README with CRLF line endings is written back with CRLF; one that mixes line endings is * refused. * @@ -49,9 +50,8 @@ const ANY_CHANGESETS = /\s*/g; /** A version as Changesets writes one, prerelease included. */ const VERSION = /\b\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?\b/g; -/** A version the README names as the one on npm, as `release-status.test.ts` reads it. */ -const ON_NPM = - /\b\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?=,\s+the\s+version\s+on\s+npm\b|\s+is\s+on\s+npm\b)/g; +/** The release-line marker, as `release-status.test.ts` reads it: **The `0.0` line.** */ +const LINE_MARKER = /\*\*The `\d+\.\d+`(\s+)line\.\*\*/g; /** A version Changesets can write, with nothing a replacement could read as a pattern. */ const USABLE_VERSION = /^[0-9A-Za-z.+-]+$/; @@ -228,18 +228,22 @@ function rewriteLf( reason: `${String(moved.length)} released bullet(s) have no What the latest release ships list to move into`, }; } - text = withMoved.replace(ON_NPM, () => version); + const line = version.split(".").slice(0, 2).join("."); + text = withMoved.replace( + LINE_MARKER, + (_marker, space: string) => `**The \`${line}\`${space}line.**`, + ); return { ok: true, changed: text !== readme, text, moved: moved.length, kept, narrowed }; } /** * Move each next-release bullet whose changesets are all consumed, given the ones still pending, up - * into What the latest release ships, and name `version` as the one on npm. + * into What the latest release ships, and name the release line of `version`. * * @example * ```ts * const result = rewriteNextRelease(readme, ["xml-format"], "0.0.4"); - * // result.ok && result.text keeps the xml-format bullet and names 0.0.4 as the version on npm + * // result.ok && result.text keeps the xml-format bullet and names the 0.0 line * ``` */ export function rewriteNextRelease( @@ -305,7 +309,7 @@ export function syncNextRelease(root: string): NextReleaseResult { result.narrowed === 0 ? "" : `, ${String(result.narrowed)} naming only pending changesets`; return { code: 0, - message: `sync-next-release: README.md moved ${String(result.moved)} released bullet(s) up; ${String(result.kept)} left${narrowed}; the version lines name ${version}`, + message: `sync-next-release: README.md moved ${String(result.moved)} released bullet(s) up; ${String(result.kept)} left${narrowed}; the release line is ${version.split(".").slice(0, 2).join(".")}`, }; } catch (error) { const code = (error as NodeJS.ErrnoException).code ?? "an unparsable file"; diff --git a/scripts/sync-next-release.ts b/scripts/sync-next-release.ts index 11f09c24..a7e5f999 100644 --- a/scripts/sync-next-release.ts +++ b/scripts/sync-next-release.ts @@ -2,9 +2,9 @@ /** * The release's `version` script runs this after `changeset version`, from the repo root: it moves * each README "In the next release" bullet whose changesets that step consumed up into "What the - * latest release ships", and names the new version as the one on npm. The rules are in - * `scripts/next-release-sync.ts`. The report goes to stderr and stdout stays empty; exit 0 for a - * write or an already-current file, 1 for a refusal. + * latest release ships", and names the new version's release line in the Status section. The rules + * are in `scripts/next-release-sync.ts`. The report goes to stderr and stdout stays empty; exit 0 + * for a write or an already-current file, 1 for a refusal. */ import { syncNextRelease } from "./next-release-sync.js"; diff --git a/test/readme.test.ts b/test/readme.test.ts new file mode 100644 index 00000000..1fcf1717 --- /dev/null +++ b/test/readme.test.ts @@ -0,0 +1,23 @@ +// The README against the house skeleton every package README shares: the tile, the package name as +// its title, the tagline and four badges, the required sections in order with License last, and a +// link to the package's page on docs.cosyte.com. npm shows this file, so a reader arriving from npm, +// GitHub or the docs site finds the same page in the same order. `pnpm check:readme` runs the same +// check from the command line. +import { readFileSync } from "node:fs"; +import { join } from "node:path"; + +import { checkReadme } from "@cosyte/script-utils/readme"; +import { describe, expect, it } from "vitest"; + +const ROOT = join(import.meta.dirname, ".."); + +describe("the README", () => { + it("follows the house skeleton", () => { + const readme = readFileSync(join(ROOT, "README.md"), "utf8"); + const manifest = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8")) as Record< + string, + unknown + >; + expect(checkReadme(readme, manifest).map((f) => `${String(f.line)} [${f.rule}]`)).toEqual([]); + }); +}); diff --git a/test/release-status.test.ts b/test/release-status.test.ts index 61badbcc..fd85d88d 100644 --- a/test/release-status.test.ts +++ b/test/release-status.test.ts @@ -10,7 +10,9 @@ import { afterAll, describe, expect, it } from "vitest"; // in an HTML comment, ``. The release pull request consumes those // changesets into CHANGELOG.md, so this test fails on it until the bullet moves up. With no // changeset pending, the section may be empty or gone; while one is, it lists at least one bullet. -// npm shows the README, so each version it names as the one on npm is package.json's. +// npm shows the README, so the release line its Status names (**The `0.0` line.**) is the one +// package.json is on, and it names no exact version as the one on npm: an exact version is stale +// after one release. const ROOT = join(import.meta.dirname, ".."); @@ -65,20 +67,42 @@ function nextReleaseBullets(readme: string): string[] { .map((b) => b.split(/\n\n/)[0] ?? b); } -/** A version the README names as the one on npm: "0.0.3, the version on npm", "0.0.3 is on npm". */ +/** An exact version named as the one on npm: "0.0.3, the version on npm", "0.0.3 is on npm". */ const ON_NPM = /\b\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?=,\s+the\s+version\s+on\s+npm\b|\s+is\s+on\s+npm\b)/g; +/** The release-line marker: **The `0.0` line.** */ +const LINE_MARKER = /\*\*The `(\d+\.\d+)`\s+line\.\*\*/g; + +/** The text of the README's `## Status` section, or undefined when it has none. */ +function statusSection(readme: string): string | undefined { + const start = readme.indexOf("\n## Status\n"); + if (start === -1) return undefined; + const end = readme.indexOf("\n## ", start + 1); + return readme.slice(start, end === -1 ? readme.length : end); +} + /** - * Why the README is wrong about the version on npm, or nothing. npm shows the README of the version - * it serves, so each version the README names as the one on npm is package.json's, and it names one. + * Why the README is wrong about its release, or nothing. npm shows the README of the version it + * serves, so its Status names package.json's release line, once, and nothing names an exact version + * as the one on npm. */ -function wrongNpmVersion(readme: string, version: string): string[] { - const named = [...readme.matchAll(ON_NPM)].map((m) => m[0]); - if (named.length === 0) return ["the README names no version as the one on npm"]; - return named - .filter((v) => v !== version) - .map((v) => `the README says ${v} is on npm, but package.json holds ${version}`); +function wrongReleaseLine(readme: string, version: string): string[] { + const exact = [...readme.matchAll(ON_NPM)].map( + (m) => `the README names ${m[0]} as the one on npm, where it names the release line`, + ); + const status = statusSection(readme); + if (status === undefined) return [...exact, "the README has no Status section"]; + const lines = [...status.matchAll(LINE_MARKER)].map((m) => String(m[1])); + if (lines.length !== 1) { + return [...exact, `the README's Status names ${String(lines.length)} release lines, not one`]; + } + const line = version.split(".").slice(0, 2).join("."); + if (lines[0] === line) return exact; + return [ + ...exact, + `the README's Status names the ${String(lines[0])} line, but package.json holds ${version}`, + ]; } /** The first line of a pending changeset's summary, or undefined once it is consumed. */ @@ -143,8 +167,8 @@ describe("release status", () => { expect(unreleasedClaims(pkg.description)).toEqual([]); }); - it("the README names package.json's version as the one on npm", () => { - expect(wrongNpmVersion(read("README.md"), pkg.version)).toEqual([]); + it("the README's Status names package.json's release line, and no exact version", () => { + expect(wrongReleaseLine(read("README.md"), pkg.version)).toEqual([]); }); it("the README lists something in the next release while a changeset is pending", () => { @@ -215,24 +239,45 @@ describe("release status", () => { expect(staleNextRelease(readme([]), "", empty)).toEqual([]); }); - it("passes a README whose every on-npm line names the version", () => { - const text = "What follows is in 0.0.4, the version on npm:\n\nReleased: 0.0.4\nis on npm.\n"; - expect(wrongNpmVersion(text, "0.0.4")).toEqual([]); + const status = (text: string): string => `# Synthetic\n\n## Status\n\n${text}\n\n## Install\n`; + + it("passes a README whose Status names the release line of package.json's version", () => { + expect(wrongReleaseLine(status("**The `0.0` line.** Released on npm."), "0.0.4")).toEqual([]); + expect(wrongReleaseLine(status("**The `0.1`\nline.**"), "0.1.12")).toEqual([]); }); - it("fails a README that names another version as the one on npm", () => { - const text = "What follows is in 0.0.3, the version on npm:\n\nReleased: 0.0.4 is on npm.\n"; - expect(wrongNpmVersion(text, "0.0.4")).toEqual([ - "the README says 0.0.3 is on npm, but package.json holds 0.0.4", + it("fails a README whose Status names another release line", () => { + expect(wrongReleaseLine(status("**The `0.0` line.**"), "0.1.0")).toEqual([ + "the README's Status names the 0.0 line, but package.json holds 0.1.0", ]); - expect(wrongNpmVersion("Released: 0.0.4-rc.1 is on npm.", "0.0.4")).toEqual([ - "the README says 0.0.4-rc.1 is on npm, but package.json holds 0.0.4", + }); + + it("fails a README whose Status names no release line, or two", () => { + expect(wrongReleaseLine(status("Released on npm."), "0.0.4")).toEqual([ + "the README's Status names 0 release lines, not one", + ]); + expect(wrongReleaseLine(status("**The `0.0` line.** **The `0.0` line.**"), "0.0.4")).toEqual([ + "the README's Status names 2 release lines, not one", + ]); + // A marker outside Status does not count. + expect(wrongReleaseLine(`**The \`0.0\` line.**${status("Early.")}`, "0.0.4")).toEqual([ + "the README's Status names 0 release lines, not one", + ]); + expect(wrongReleaseLine("# Synthetic\n\n**The `0.0` line.**\n", "0.0.4")).toEqual([ + "the README has no Status section", ]); }); - it("fails a README that names no version as the one on npm", () => { - expect(wrongNpmVersion("Pathways is on npm.", "0.0.4")).toEqual([ - "the README names no version as the one on npm", + it("fails a README that names an exact version as the one on npm", () => { + const text = status("**The `0.0` line.** What follows is in 0.0.4, the version on npm."); + expect(wrongReleaseLine(text, "0.0.4")).toEqual([ + "the README names 0.0.4 as the one on npm, where it names the release line", + ]); + expect( + wrongReleaseLine(`Released: 0.0.4-rc.1 is on npm.${status("Early.")}`, "0.0.4"), + ).toEqual([ + "the README names 0.0.4-rc.1 as the one on npm, where it names the release line", + "the README's Status names 0 release lines, not one", ]); }); diff --git a/test/scripts/sync-next-release.test.ts b/test/scripts/sync-next-release.test.ts index 401b0102..0dcd783c 100644 --- a/test/scripts/sync-next-release.test.ts +++ b/test/scripts/sync-next-release.test.ts @@ -56,7 +56,7 @@ const SECTION = [ const LATEST = [ "## What the latest release ships", "", - "What follows is in 0.0.3, the version on npm:", + "What follows is in the latest release, the one on npm:", "", "- **Old.** A synthetic thing an earlier release shipped.", "", @@ -64,26 +64,23 @@ const LATEST = [ "", ].join("\n"); -const STATUS = "## Status\n\nEarly, and released: 0.0.3 is on npm.\n"; +const STATUS = "## Status\n\n**The `0.0` line.** Early, and released on npm.\n"; -/** A version named as the one on npm, as the release-status test reads it. */ -const ON_NPM = /\b\d+\.\d+\.\d+(?=,\s+the\s+version\s+on\s+npm\b|\s+is\s+on\s+npm\b)/g; +/** The release line the README names, as the release-status test reads it. */ +const LINE = /\*\*The `(\d+\.\d+)`\s+line\.\*\*/g; const README = `# Synthetic\n\n${CONTENTS}\n---\n\n${LATEST}${SECTION}${STATUS}`; -/** The README with the latest-release list holding `moved` and every on-npm line naming 0.0.4. */ +/** The README with the latest-release list holding `moved`; 0.0.4 is still on the 0.0 line. */ function released(text: string, moved: readonly string[]): string { - return text - .replace( - "- **Old.** A synthetic thing an earlier release shipped.\n", - ["- **Old.** A synthetic thing an earlier release shipped.", ...moved, ""].join("\n"), - ) - .replace("in 0.0.3, the version on npm", "in 0.0.4, the version on npm") - .replace("0.0.3 is on npm", "0.0.4 is on npm"); + return text.replace( + "- **Old.** A synthetic thing an earlier release shipped.\n", + ["- **Old.** A synthetic thing an earlier release shipped.", ...moved, ""].join("\n"), + ); } describe("rewriteNextRelease", () => { - it("moves a released bullet up, without its comment, and names the new version", () => { + it("moves a released bullet up, without its comment, keeping a current release line", () => { const result = rewriteNextRelease(README, ["pending-thing"], "0.0.4"); expect(result).toEqual({ ok: true, @@ -152,7 +149,7 @@ describe("rewriteNextRelease", () => { it("keeps the blank lines between the bullets it keeps in such a list", () => { const text = [ - "# Synthetic\n\n## What the latest release ships\n\nIn 0.0.3, the version on npm:\n\n- **Old.** Shipped.\n", + "# Synthetic\n\n## What the latest release ships\n\nIn the latest release:\n\n- **Old.** Shipped.\n", "## In the next release\n\n- Gone. \n\n- One. ", " More of one.\n\n A second paragraph of one.\n\n- Two. \n\nEnd.\n", ].join("\n"); @@ -174,24 +171,27 @@ describe("rewriteNextRelease", () => { ); }); - it("rewrites the version lines when the README has no next-release section", () => { + it("names a new release line when the README has no next-release section", () => { const text = `# Synthetic\n\n${LATEST}${STATUS}`; - expect(rewriteNextRelease(text, [], "0.0.4")).toEqual({ + expect(rewriteNextRelease(text, [], "0.1.0")).toEqual({ ok: true, changed: true, moved: 0, kept: 0, narrowed: 0, - text: released(text, []), + text: text.replace("**The `0.0` line.**", "**The `0.1` line.**"), }); }); - it("rewrites a version line wrapped over two lines", () => { - const text = "# Synthetic\n\nEarly, and released:\n0.0.3\nis on npm.\n"; - const result = rewriteNextRelease(text, [], "0.0.4"); - expect(result.ok && result.text).toBe( - "# Synthetic\n\nEarly, and released:\n0.0.4\nis on npm.\n", - ); + it("leaves the release line as it is for a version on the same line", () => { + const text = `# Synthetic\n\n${LATEST}${STATUS}`; + expect(rewriteNextRelease(text, [], "0.0.9")).toMatchObject({ ok: true, changed: false }); + }); + + it("names a new release line in a marker wrapped over two lines", () => { + const text = "# Synthetic\n\nEarly. **The `0.0`\nline.** Released.\n"; + const result = rewriteNextRelease(text, [], "1.2.0"); + expect(result.ok && result.text).toBe("# Synthetic\n\nEarly. **The `1.2`\nline.** Released.\n"); }); it("leaves a README with no such sections untouched", () => { @@ -349,9 +349,9 @@ describe("syncNextRelease and the script", () => { }); // What npm shows for the release: every bullet it shipped is under What the latest release ships, - // without its comment, and the README names the new version as the one on npm. On the Version + // without its comment, and the README names the new version's release line. On the Version // Packages commit itself the README has no next-release bullets left, and this still holds. - it("moves the repository's released bullets up and names the new version on npm", () => { + it("moves the repository's released bullets up and names the new release line", () => { const bullets = nextReleaseTexts(repoReadme); layout({ version: "9.9.9" }, repoReadme, []); expect(syncNextRelease(dir).code).toBe(0); @@ -359,10 +359,7 @@ describe("syncNextRelease and the script", () => { const latest = sectionOf(after, "## What the latest release ships"); for (const bullet of bullets) expect(latest).toContain(bullet); expect(latest).not.toContain("