fix: 修复 vitest 迁移后测试失败

- async 函数断言改用 await expect().rejects.toThrow()
- 所有局部 runCli 从 tsx 改为 node
- rest params (...args) 改为 array params (args)
- 更新 snapshots

36/36 files pass, 617/617 tests pass

Fixes #64
This commit is contained in:
2026-06-03 06:16:33 +00:00
parent 05f3246e5b
commit 32b520b2a4
19 changed files with 601 additions and 130 deletions
@@ -1,5 +1,528 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`Phase 3: Variable System > 3.1 var set creates variable 1`] = `
{
"type": "0Q5EMYK4SYSS9",
"value": {
"labels": [],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {},
"value": "9W3MGR3184QYE",
},
}
`;
exports[`Phase 3: Variable System > 3.2 var get returns variable 1`] = `
{
"type": "F5RRJTXP8Z99D",
"value": {
"labels": [],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {},
"value": "9W3MGR3184QYE",
},
}
`;
exports[`Phase 3: Variable System > 3.3 var list shows all variables 1`] = `
{
"type": "AF0XACGXHPMC1",
"value": [
{
"labels": [],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {},
"value": "9W3MGR3184QYE",
},
{
"labels": [],
"name": "@ocas/array",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "D45CW047XS17Y",
},
{
"labels": [],
"name": "@ocas/bool",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "1AVHCXEJVDCPP",
},
{
"labels": [],
"name": "@ocas/boolean",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "1AVHCXEJVDCPP",
},
{
"labels": [],
"name": "@ocas/integer",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "B26JM4PBHPAFK",
},
{
"labels": [],
"name": "@ocas/null",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "8E33KAS0HMAZ7",
},
{
"labels": [],
"name": "@ocas/number",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "BEAZQGKVXMZT8",
},
{
"labels": [],
"name": "@ocas/object",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "944RT37WX1PQ5",
},
{
"labels": [],
"name": "@ocas/output/gc",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "7KHZTY010988K",
},
{
"labels": [],
"name": "@ocas/output/get",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "7V5G8E2VW8B2G",
},
{
"labels": [],
"name": "@ocas/output/has",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "FHXQQZMVHW924",
},
{
"labels": [],
"name": "@ocas/output/hash",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "1B24CBF95Q5G6",
},
{
"labels": [],
"name": "@ocas/output/list",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "7BWZ3JKKMSH4N",
},
{
"labels": [],
"name": "@ocas/output/list-meta",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "1WQ7C0EV8QGA4",
},
{
"labels": [],
"name": "@ocas/output/list-schema",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "7FYGS2KQ3REM9",
},
{
"labels": [],
"name": "@ocas/output/put",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "4ZHWK21APCFZ5",
},
{
"labels": [],
"name": "@ocas/output/refs",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "2TKP4RGBJ4V43",
},
{
"labels": [],
"name": "@ocas/output/tag",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "CPSWA9TB2JMWP",
},
{
"labels": [],
"name": "@ocas/output/template-delete",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "BY7BGZJND3N7R",
},
{
"labels": [],
"name": "@ocas/output/template-get",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "0B0HBHZGYHR84",
},
{
"labels": [],
"name": "@ocas/output/template-list",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "8917JQTD1R5JF",
},
{
"labels": [],
"name": "@ocas/output/template-set",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "BJDHPAE4Q8TXM",
},
{
"labels": [],
"name": "@ocas/output/untag",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "BPEQMRQNJK80Z",
},
{
"labels": [],
"name": "@ocas/output/var-delete",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "C3MYPR5RGQFZT",
},
{
"labels": [],
"name": "@ocas/output/var-get",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "F5RRJTXP8Z99D",
},
{
"labels": [],
"name": "@ocas/output/var-history",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "EVZJS80TRFKE1",
},
{
"labels": [],
"name": "@ocas/output/var-list",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "AF0XACGXHPMC1",
},
{
"labels": [],
"name": "@ocas/output/var-set",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "0Q5EMYK4SYSS9",
},
{
"labels": [],
"name": "@ocas/output/verify",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "52HEFB52BD0GF",
},
{
"labels": [],
"name": "@ocas/output/walk",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "4HG6MD3XG5H5C",
},
{
"labels": [],
"name": "@ocas/schema",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "CTS5P6RD8HMCS",
},
{
"labels": [],
"name": "@ocas/string",
"schema": "CTS5P6RD8HMCS",
"tags": {},
"value": "7VQ43ZSJTEWA7",
},
],
}
`;
exports[`Phase 3: Variable System > 3.4 var list prefix filters by prefix 1`] = `
{
"type": "AF0XACGXHPMC1",
"value": [
{
"labels": [],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {},
"value": "9W3MGR3184QYE",
},
],
}
`;
exports[`Phase 3: Variable System > 3.5 var set upsert updates existing variable 1`] = `
{
"type": "0Q5EMYK4SYSS9",
"value": {
"labels": [],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {},
"value": "A6QPKJAFR68NP",
},
}
`;
exports[`Phase 3: Variable System > 3.6 var set with tag and label adds them 1`] = `
{
"type": "0Q5EMYK4SYSS9",
"value": {
"labels": [
"important",
],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {
"env": "prod",
},
"value": "9W3MGR3184QYE",
},
}
`;
exports[`Phase 3: Variable System > 3.7 var list --tag env:prod filters by kv tag 1`] = `
{
"type": "AF0XACGXHPMC1",
"value": [
{
"labels": [
"important",
],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {
"env": "prod",
},
"value": "9W3MGR3184QYE",
},
],
}
`;
exports[`Phase 3: Variable System > 3.8 var list --tag important filters by label 1`] = `
{
"type": "AF0XACGXHPMC1",
"value": [
{
"labels": [
"important",
],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {
"env": "prod",
},
"value": "9W3MGR3184QYE",
},
],
}
`;
exports[`Phase 3: Variable System > 3.9 var set without label removes it 1`] = `
{
"type": "0Q5EMYK4SYSS9",
"value": {
"labels": [],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {
"env": "prod",
},
"value": "9W3MGR3184QYE",
},
}
`;
exports[`Phase 3: Variable System > 3.10 var delete removes variable 1`] = `
{
"type": "C3MYPR5RGQFZT",
"value": [
{
"labels": [],
"name": "@myapp/config",
"schema": "FRBAB1BF0ZBCS",
"tags": {
"env": "prod",
},
"value": "9W3MGR3184QYE",
},
],
}
`;
exports[`Phase 3: Variable System > 3.11 var get deleted variable returns not found 1`] = `"Error: Variable not found: name=@myapp/config, schema=FRBAB1BF0ZBCS"`;
exports[`Phase 4: Template System > 4.1 template set registers template 1`] = `
{
"type": "BJDHPAE4Q8TXM",
"value": {
"contentHash": "6WW8WNB38GTTP",
"schemaHash": "FRBAB1BF0ZBCS",
},
}
`;
exports[`Phase 4: Template System > 4.2 template get returns template text 1`] = `
{
"type": "0B0HBHZGYHR84",
"value": "Name: {{ payload.name }}, Age: {{ payload.age }}",
}
`;
exports[`Phase 4: Template System > 4.3 template list shows registered templates 1`] = `
{
"type": "8917JQTD1R5JF",
"value": [
{
"contentHash": "6WW8WNB38GTTP",
"schemaHash": "FRBAB1BF0ZBCS",
},
],
}
`;
exports[`Phase 4: Template System > 4.4 template delete removes template 1`] = `
{
"type": "BY7BGZJND3N7R",
"value": {
"deleted": true,
},
}
`;
exports[`Phase 4: Template System > 4.5 template get deleted template returns not found 1`] = `"Error: Template not found for schema: FRBAB1BF0ZBCS"`;
exports[`Phase 7: Edge Cases > 7.1 get non-existent hash errors gracefully 1`] = `"Node not found: AAAAAAAAAAAAA"`;
exports[`Phase 7: Edge Cases > 7.3 var set empty name errors 1`] = `"Usage: ocas var set <name> <hash> [--tag <tag>...]"`;
exports[`Phase 7: Edge Cases > 7.4 var set name with invalid chars errors 1`] = `"Error: Invalid variable name "invalid name!": Name must follow @scope/name format (e.g. @myapp/config)"`;
exports[`Phase 7: Edge Cases > 7.5 no subcommand shows help text 1`] = `
"Usage: ocas [--home <path>] [--json] <command> [args]
All JSON commands emit a { type, value } envelope. The type is the hash of the
command's @ocas/output/* schema (shown in parentheses); pipe any envelope into
\`render -p\` to render its value (ocas_ref hashes are expanded).
Commands:
put <type-hash> <file.json|--pipe> Store node, print envelope (value=hash) (@ocas/output/put)
get <hash> Print node as envelope (@ocas/output/get)
has <hash> Print envelope (value=boolean) (@ocas/output/has)
verify <hash> Verify integrity + schema (value=ok/corrupted/invalid) (@ocas/output/verify)
refs <hash> List direct ocas_ref edges (@ocas/output/refs)
walk <hash> [--format tree] Recursive traversal (@ocas/output/walk)
hash <type-hash> <file.json|--pipe> Compute hash without storing (@ocas/output/hash)
render <hash> [options] Render node as text with resolution decay (raw output)
render --pipe/-p [options] Render { type, value } from stdin (raw output)
list --type <hash-or-name> [--tag <tag>...] List hashes for a type, optionally filtered by tags (@ocas/output/list)
list-meta List meta-schema hashes (value=string[]) (@ocas/output/list-meta)
list-schema List all schema hashes (value=string[]) (@ocas/output/list-schema)
tag <target> <tag>... Apply tags/labels to a target (@ocas/output/tag)
untag <target> <tag>... Remove tags/labels from a target (@ocas/output/untag)
var set <name> <hash> [--tag <tag>...] Create/update a variable (@ocas/output/var-set)
var get <name> --schema <hash> Get a variable by name + schema (@ocas/output/var-get)
var delete <name> [--schema <hash>] Delete variable(s) (@ocas/output/var-delete)
var list [prefix] [--schema <hash>] [--tag <tag>...] List variables (@ocas/output/var-list)
var history <name> [--schema <hash>] Show value history (LRU) (@ocas/output/var-history)
template set <schema-hash> <file> | --inline <text> Set template for schema (@ocas/output/template-set)
template get <schema-hash> Get template content (value=string) (@ocas/output/template-get)
template list List all templates (@ocas/output/template-list)
template delete <schema-hash> Delete template for schema (@ocas/output/template-delete)
gc Run garbage collection (@ocas/output/gc)
Flags:
--home <path> Store directory (default: $OCAS_HOME or ~/.ocas)
--json Compact JSON output
--render, -r Render output inline (equivalent to | ocas render -p)
--schema <hash> Schema hash filter for var get/delete/tag/list
--tag <tag> Tag/label (can be repeated): key:value (tag), name (label), :name (delete)
--inline <text> Inline text content for template set
--resolution <n> Initial resolution for render (default: 1.0)
--decay <n> Decay factor for render (default: 0.5)
--epsilon <n> Cutoff threshold for render (default: 0.01)
--pipe, -p Read from stdin (put/hash: raw JSON payload; render: { type, value } envelope)
Agent: If you have not installed the ocas skill for this version (0.2.0), run \`ocas prompt setup\` and follow the instructions."
`;
exports[`Phase 7: Edge Cases 7.1 get non-existent hash errors gracefully 1`] = `"Node not found: AAAAAAAAAAAAA"`;
exports[`Phase 7: Edge Cases 7.3 var set empty name errors 1`] = `"Usage: ocas var set <name> <hash> [--tag <tag>...]"`;
exports[`Phase 7: Edge Cases 7.4 var set name with invalid chars errors 1`] = `"Error: Invalid variable name "invalid name!": Name must follow @scope/name format (e.g. @myapp/config)"`;
exports[`Phase 7: Edge Cases 7.5 no subcommand shows help text 1`] = `
"Usage: ocas [--home <path>] [--json] <command> [args]
All JSON commands emit a { type, value } envelope. The type is the hash of the
command's @ocas/output/* schema (shown in parentheses); pipe any envelope into
\`render -p\` to render its value (ocas_ref hashes are expanded).
Commands:
put <type-hash> <file.json|--pipe> Store node, print envelope (value=hash) (@ocas/output/put)
get <hash> Print node as envelope (@ocas/output/get)
has <hash> Print envelope (value=boolean) (@ocas/output/has)
verify <hash> Verify integrity + schema (value=ok/corrupted/invalid) (@ocas/output/verify)
refs <hash> List direct ocas_ref edges (@ocas/output/refs)
walk <hash> [--format tree] Recursive traversal (@ocas/output/walk)
hash <type-hash> <file.json|--pipe> Compute hash without storing (@ocas/output/hash)
render <hash> [options] Render node as text with resolution decay (raw output)
render --pipe/-p [options] Render { type, value } from stdin (raw output)
list --type <hash-or-name> [--tag <tag>...] List hashes for a type, optionally filtered by tags (@ocas/output/list)
list-meta List meta-schema hashes (value=string[]) (@ocas/output/list-meta)
list-schema List all schema hashes (value=string[]) (@ocas/output/list-schema)
tag <target> <tag>... Apply tags/labels to a target (@ocas/output/tag)
untag <target> <tag>... Remove tags/labels from a target (@ocas/output/untag)
var set <name> <hash> [--tag <tag>...] Create/update a variable (@ocas/output/var-set)
var get <name> --schema <hash> Get a variable by name + schema (@ocas/output/var-get)
var delete <name> [--schema <hash>] Delete variable(s) (@ocas/output/var-delete)
var list [prefix] [--schema <hash>] [--tag <tag>...] List variables (@ocas/output/var-list)
var history <name> [--schema <hash>] Show value history (LRU) (@ocas/output/var-history)
template set <schema-hash> <file> | --inline <text> Set template for schema (@ocas/output/template-set)
template get <schema-hash> Get template content (value=string) (@ocas/output/template-get)
template list List all templates (@ocas/output/template-list)
template delete <schema-hash> Delete template for schema (@ocas/output/template-delete)
gc Run garbage collection (@ocas/output/gc)
Flags:
--home <path> Store directory (default: $OCAS_HOME or ~/.ocas)
--json Compact JSON output
--render, -r Render output inline (equivalent to | ocas render -p)
--schema <hash> Schema hash filter for var get/delete/tag/list
--tag <tag> Tag/label (can be repeated): key:value (tag), name (label), :name (delete)
--inline <text> Inline text content for template set
--resolution <n> Initial resolution for render (default: 1.0)
--decay <n> Decay factor for render (default: 0.5)
--epsilon <n> Cutoff threshold for render (default: 0.01)
--pipe, -p Read from stdin (put/hash: raw JSON payload; render: { type, value } envelope)
Agent: If you have not installed the ocas skill for this version (0.2.0), run \`ocas prompt setup\` and follow the instructions."
`;
exports[`Phase 3: Variable System 3.1 var set creates variable 1`] = `
{
"type": "0Q5EMYK4SYSS9",
@@ -375,8 +898,6 @@ exports[`Phase 3: Variable System 3.10 var delete removes variable 1`] = `
exports[`Phase 3: Variable System 3.11 var get deleted variable returns not found 1`] = `"Error: Variable not found: name=@myapp/config, schema=FRBAB1BF0ZBCS"`;
exports[`Phase 4: Template System > 4.5 template get deleted template returns not found 1`] = `"Unknown command: template,get,FRBAB1BF0ZBCS"`;
exports[`Phase 4: Template System 4.1 template set registers template 1`] = `
{
"type": "BJDHPAE4Q8TXM",
@@ -416,57 +937,3 @@ exports[`Phase 4: Template System 4.4 template delete removes template 1`] = `
`;
exports[`Phase 4: Template System 4.5 template get deleted template returns not found 1`] = `"Error: Template not found for schema: FRBAB1BF0ZBCS"`;
exports[`Phase 7: Edge Cases 7.1 get non-existent hash errors gracefully 1`] = `"Node not found: AAAAAAAAAAAAA"`;
exports[`Phase 7: Edge Cases 7.3 var set empty name errors 1`] = `"Usage: ocas var set <name> <hash> [--tag <tag>...]"`;
exports[`Phase 7: Edge Cases 7.4 var set name with invalid chars errors 1`] = `"Error: Invalid variable name "invalid name!": Name must follow @scope/name format (e.g. @myapp/config)"`;
exports[`Phase 7: Edge Cases 7.5 no subcommand shows help text 1`] = `
"Usage: ocas [--home <path>] [--json] <command> [args]
All JSON commands emit a { type, value } envelope. The type is the hash of the
command's @ocas/output/* schema (shown in parentheses); pipe any envelope into
\`render -p\` to render its value (ocas_ref hashes are expanded).
Commands:
put <type-hash> <file.json|--pipe> Store node, print envelope (value=hash) (@ocas/output/put)
get <hash> Print node as envelope (@ocas/output/get)
has <hash> Print envelope (value=boolean) (@ocas/output/has)
verify <hash> Verify integrity + schema (value=ok/corrupted/invalid) (@ocas/output/verify)
refs <hash> List direct ocas_ref edges (@ocas/output/refs)
walk <hash> [--format tree] Recursive traversal (@ocas/output/walk)
hash <type-hash> <file.json|--pipe> Compute hash without storing (@ocas/output/hash)
render <hash> [options] Render node as text with resolution decay (raw output)
render --pipe/-p [options] Render { type, value } from stdin (raw output)
list --type <hash-or-name> [--tag <tag>...] List hashes for a type, optionally filtered by tags (@ocas/output/list)
list-meta List meta-schema hashes (value=string[]) (@ocas/output/list-meta)
list-schema List all schema hashes (value=string[]) (@ocas/output/list-schema)
tag <target> <tag>... Apply tags/labels to a target (@ocas/output/tag)
untag <target> <tag>... Remove tags/labels from a target (@ocas/output/untag)
var set <name> <hash> [--tag <tag>...] Create/update a variable (@ocas/output/var-set)
var get <name> --schema <hash> Get a variable by name + schema (@ocas/output/var-get)
var delete <name> [--schema <hash>] Delete variable(s) (@ocas/output/var-delete)
var list [prefix] [--schema <hash>] [--tag <tag>...] List variables (@ocas/output/var-list)
var history <name> [--schema <hash>] Show value history (LRU) (@ocas/output/var-history)
template set <schema-hash> <file> | --inline <text> Set template for schema (@ocas/output/template-set)
template get <schema-hash> Get template content (value=string) (@ocas/output/template-get)
template list List all templates (@ocas/output/template-list)
template delete <schema-hash> Delete template for schema (@ocas/output/template-delete)
gc Run garbage collection (@ocas/output/gc)
Flags:
--home <path> Store directory (default: $OCAS_HOME or ~/.ocas)
--json Compact JSON output
--render, -r Render output inline (equivalent to | ocas render -p)
--schema <hash> Schema hash filter for var get/delete/tag/list
--tag <tag> Tag/label (can be repeated): key:value (tag), name (label), :name (delete)
--inline <text> Inline text content for template set
--resolution <n> Initial resolution for render (default: 1.0)
--decay <n> Decay factor for render (default: 0.5)
--epsilon <n> Cutoff threshold for render (default: 0.01)
--pipe, -p Read from stdin (put/hash: raw JSON payload; render: { type, value } envelope)
Agent: If you have not installed the ocas skill for this version (0.2.0), run \`ocas prompt setup\` and follow the instructions."
`;
@@ -1,5 +1,9 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`Phase 5: Render > 5.1 render fills payload variables 1`] = `"Hello Alice!"`;
exports[`Phase 5: Render > 5.2 render --resolution with different value 1`] = `"Hello Alice!"`;
exports[`Phase 5: Render 5.1 render fills payload variables 1`] = `"Hello Alice!"`;
exports[`Phase 5: Render 5.2 render --resolution with different value 1`] = `"Hello Alice!"`;
+1 -1
View File
@@ -37,7 +37,7 @@ afterEach(() => {
*/
function runCliAlias(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], {
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
encoding: "utf-8",
timeout: 10000,
});
+8 -8
View File
@@ -24,7 +24,7 @@ describe("ocas binary", () => {
});
test("T3: ocas command is executable and shows help", () => {
const stdout = execFileSync("tsx", [entrypoint, "--help"], {
const stdout = execFileSync("node", [entrypoint, "--help"], {
encoding: "utf-8",
timeout: 10000,
});
@@ -39,9 +39,9 @@ describe("Phase 7: Edge Cases", () => {
let typeHash: string;
let nodeHash: string;
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
encoding: "utf-8",
timeout: 10000,
});
@@ -127,7 +127,7 @@ describe("Phase 7: Edge Cases", () => {
const fileAsStore = join(tmpStore, "not-a-directory");
writeFileSync(fileAsStore, "test");
try {
execFileSync("tsx", [entrypoint, "--home", fileAsStore, "get", "AAAAAAAAAAAAA"], {
execFileSync("node", [entrypoint, "--home", fileAsStore, "get", "AAAAAAAAAAAAA"], {
encoding: "utf-8",
timeout: 10000,
});
@@ -147,9 +147,9 @@ describe("Phase 3: Variable System", () => {
let typeHash: string;
let nodeHash: string;
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
encoding: "utf-8",
timeout: 10000,
});
@@ -336,9 +336,9 @@ describe("Phase 4: Template System", () => {
let tmpStore: string;
let typeHash: string;
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
encoding: "utf-8",
timeout: 10000,
});
+3 -3
View File
@@ -42,9 +42,9 @@ afterAll(() => {
rmSync(tmpStore, { recursive: true, force: true });
});
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
encoding: "utf-8",
timeout: 10000,
});
@@ -76,7 +76,7 @@ describe("Phase 6: GC", () => {
const { stdout: gcOut, exitCode: gcExit } = runCli(["gc"]);
expect(gcExit).toBe(0);
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, "render", "--pipe"], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, "render", "--pipe"], {
input: gcOut,
encoding: "utf-8",
timeout: 10000,
+1 -1
View File
@@ -32,7 +32,7 @@ afterEach(() => {
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], {
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
encoding: "utf-8",
timeout: 10000,
});
+1 -1
View File
@@ -20,7 +20,7 @@ afterEach(() => {
async function putString(text: string): Promise<string> {
const entrypoint = join(import.meta.dirname, "../src/index.ts");
const out = execFileSync("tsx", [entrypoint, "--home", storePath, "put", "@ocas/string", "--pipe"], {
const out = execFileSync("node", [entrypoint, "--home", storePath, "put", "@ocas/string", "--pipe"], {
input: JSON.stringify(text),
encoding: "utf-8",
timeout: 10000,
+2 -2
View File
@@ -29,7 +29,7 @@ afterEach(() => {
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], {
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
encoding: "utf-8",
timeout: 10000,
});
@@ -42,7 +42,7 @@ function runCli(...args: string[]): { stdout: string; stderr: string; exitCode:
function putString(value: string): string {
try {
const out = execFileSync("tsx", [cliPath, "--home", storePath, "put", "@ocas/string", "--pipe"], {
const out = execFileSync("node", [cliPath, "--home", storePath, "put", "@ocas/string", "--pipe"], {
input: JSON.stringify(value),
encoding: "utf-8",
timeout: 10000,
+3 -3
View File
@@ -44,9 +44,9 @@ afterAll(() => {
rmSync(tmpStore, { recursive: true, force: true });
});
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
encoding: "utf-8",
timeout: 10000,
});
@@ -62,7 +62,7 @@ function runCliWithStdin(
stdin: string,
): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
input: stdin,
encoding: "utf-8",
timeout: 10000,
+1 -1
View File
@@ -46,7 +46,7 @@ function runCli(
args: string[],
): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
encoding: "utf-8",
timeout: 10000,
});
+3 -3
View File
@@ -58,9 +58,9 @@ describe("Phase 5: Render", () => {
let typeHash: string;
let nodeHash: string;
function runCliE2e(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
function runCliE2e(args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
encoding: "utf-8",
timeout: 10000,
});
@@ -76,7 +76,7 @@ describe("Phase 5: Render", () => {
stdin: string,
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
input: stdin,
encoding: "utf-8",
timeout: 10000,
+3 -3
View File
@@ -582,7 +582,7 @@ describe("Phase 2: Schema Validation", () => {
const nodeFile = join(tmpStore, "test-node.json");
writeFileSync(nodeFile, JSON.stringify({ name: "Alice", age: 30 }));
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, "put", typeHash, nodeFile], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, "put", typeHash, nodeFile], {
encoding: "utf-8",
timeout: 10000,
}).trim();
@@ -598,7 +598,7 @@ describe("Phase 2: Schema Validation", () => {
writeFileSync(badFile, JSON.stringify({ name: 123 }));
let stdout = "", stderr = "", exitCode = 0;
try {
stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, "put", typeHash, badFile], {
stdout = execFileSync("node", [entrypoint, "--home", tmpStore, "put", typeHash, badFile], {
encoding: "utf-8",
timeout: 10000,
}).trim();
@@ -618,7 +618,7 @@ describe("Phase 2: Schema Validation", () => {
const nodeFile = join(tmpStore, "test-node.json");
let exitCode = 0, stderr = "";
try {
execFileSync("tsx", [entrypoint, "--home", tmpStore, "put", "AAAAAAAAAAAAA", nodeFile], {
execFileSync("node", [entrypoint, "--home", tmpStore, "put", "AAAAAAAAAAAAA", nodeFile], {
encoding: "utf-8",
timeout: 10000,
});
+1 -1
View File
@@ -32,7 +32,7 @@ afterEach(() => {
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], {
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
encoding: "utf-8",
timeout: 10000,
});
+1 -1
View File
@@ -40,7 +40,7 @@ afterEach(() => {
*/
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], {
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
encoding: "utf-8",
timeout: 10000,
});
+1 -1
View File
@@ -33,7 +33,7 @@ afterEach(() => {
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], {
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
encoding: "utf-8",
timeout: 10000,
});
+2 -2
View File
@@ -40,7 +40,7 @@ afterEach(() => {
*/
function runCli(...args: string[]): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [cliPath, "--home", storePath, ...args], {
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
encoding: "utf-8",
timeout: 10000,
});
@@ -770,7 +770,7 @@ describe("global options", () => {
const hash = await createTestNode(store, typeHash, { test: "data" });
// Override with custom store path
execFileSync("tsx", [cliPath, "--home", customStorePath, "var", "set", "@test/x", hash], {
execFileSync("node", [cliPath, "--home", customStorePath, "var", "set", "@test/x", hash], {
encoding: "utf-8",
timeout: 10000,
});
+1 -1
View File
@@ -43,7 +43,7 @@ function runCli(
args: string[],
): { stdout: string; stderr: string; exitCode: number } {
try {
const stdout = execFileSync("tsx", [entrypoint, "--home", tmpStore, ...args], {
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
encoding: "utf-8",
timeout: 10000,
});
+8 -8
View File
@@ -598,7 +598,7 @@ describe("Suite 4: Render Flow Integration", () => {
epsilon: 0.01,
});
expect(output.length).toBe(0);
await expect(output.length).toBe(0);
} finally {
await cleanup();
}
@@ -629,7 +629,7 @@ describe("Suite 4: Render Flow Integration", () => {
decay: 0.5,
epsilon: 0.01,
});
}).toThrow();
}).rejects.toThrow();
} finally {
await cleanup();
}
@@ -905,8 +905,8 @@ describe("Suite 6: Recursive Rendering Edge Cases", () => {
});
expect(output).toContain("Item: item1");
expect(output).toContain("Item: item2");
expect(output).toContain("Item: item3");
await expect(output).toContain("Item: item2");
await expect(output).toContain("Item: item3");
} finally {
await cleanup();
}
@@ -937,7 +937,7 @@ describe("Suite 7: Error Handling & Edge Cases", () => {
epsilon: 0.01,
});
expect(output).toBeDefined();
await expect(output).toBeDefined();
} finally {
await cleanup();
}
@@ -976,7 +976,7 @@ describe("Suite 7: Error Handling & Edge Cases", () => {
decay: 0.5,
epsilon: 0.01,
});
}).toThrow(/decay/);
}).rejects.toThrow(/decay/);
} finally {
await cleanup();
}
@@ -1015,7 +1015,7 @@ describe("Suite 7: Error Handling & Edge Cases", () => {
decay: 0.5,
epsilon: 0.01,
});
}).toThrow();
}).rejects.toThrow();
} finally {
await cleanup();
}
@@ -1054,7 +1054,7 @@ describe("Suite 7: Error Handling & Edge Cases", () => {
decay: 0.5,
epsilon: 0.01,
});
}).toThrow(/decay/);
}).rejects.toThrow(/decay/);
} finally {
await cleanup();
}
+34 -34
View File
@@ -258,169 +258,169 @@ describe("Test Suite 3: putSchema Validation - Invalid Schemas", () => {
test("3.1: Reject schema with invalid type value", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () => putSchema(store, { type: "garbage" })).toThrow();
await expect(async () => putSchema(store, { type: "garbage" })).rejects.toThrow();
});
test("3.2: Reject schema with type as number", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, { type: 123 } as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.3: Reject schema with properties not an object", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "object",
properties: "not-an-object",
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.4: Reject schema with required not an array", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "object",
required: "name",
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.5: Reject schema with required containing non-strings", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "object",
required: ["name", 123, true],
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.6: Reject schema with additionalProperties as string", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "object",
additionalProperties: "yes",
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.7: Reject schema with anyOf not an array", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
anyOf: { type: "string" },
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.8: Reject schema with empty anyOf array", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () => putSchema(store, { anyOf: [] })).toThrow();
await expect(async () => putSchema(store, { anyOf: [] })).rejects.toThrow();
});
test("3.9: Reject schema with items not an object", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "array",
items: "string",
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.10: Reject schema with format not a string", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "string",
format: 123,
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.11: Reject schema with enum not an array", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "string",
enum: "red",
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.12: Reject schema with empty enum array", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, { type: "string", enum: [] }),
).toThrow();
).rejects.toThrow();
});
test("3.13: Reject schema with title not a string", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "string",
title: 123,
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.14: Reject schema with description not a string", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "string",
description: ["not a string"],
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.15: Reject schema with unsupported $ref keyword", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
$ref: "#/definitions/user",
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.16: Reject completely invalid data (non-object)", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, "not-a-schema" as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
test("3.17: Reject nested invalid schema in properties", async () => {
const store = new MemStore();
bootstrap(store);
expect(async () =>
await expect(async () =>
putSchema(store, {
type: "object",
properties: {
name: { type: "invalid-type" },
},
} as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
});
@@ -641,9 +641,9 @@ describe("Test Suite 7: Meta-Schema Content Validation", () => {
expect(hash2).toBeTruthy();
// Invalid type (number)
expect(async () =>
await expect(async () =>
putSchema(store, { type: 123 } as unknown as JSONSchema),
).toThrow();
).rejects.toThrow();
});
});