fix: resolve test failures for issue #53
Applied tester feedback to fix 5 test failures: 1. Updated error message format from "Node not found" to "CAS node not found" for consistency with existing tests in variable-store.test.ts and var.test.ts 2. Fixed CLI tests R9 and R10 to use bootstrap() directly instead of non-existent "types" command. Added imports for bootstrap and createFsStore. 3. Fixed render test 6.5 to pass actual schema Hash instead of entire bootstrap object (Record<string, Hash>) 4. Updated test expectations in render.test.ts (tests 1.5, 10.1, 10.2) to match new error message format All 390 tests now pass. Core functionality verified: - Missing root hash detection working correctly - CLI exits with code 1 on missing hash - Error message includes hash: "CAS node not found: <hash>" - Nested nodes still render as cas: references (preserved behavior) - Resolution decay behavior preserved Fixes #53 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,8 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
||||
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { bootstrap } from "@uncaged/json-cas";
|
||||
import { createFsStore } from "@uncaged/json-cas-fs";
|
||||
|
||||
const pkgPath = resolve(import.meta.dir, "../package.json");
|
||||
const entrypoint = resolve(import.meta.dir, "index.ts");
|
||||
@@ -639,9 +641,9 @@ describe("Suite 6: CLI Integration with Templates", () => {
|
||||
try {
|
||||
await runCli(["init"], tmpStore);
|
||||
|
||||
// Get @string type hash
|
||||
const { stdout: typesJson } = await runCli(["types"], tmpStore);
|
||||
const types = JSON.parse(typesJson);
|
||||
// Get @string type hash via bootstrap
|
||||
const store = createFsStore(tmpStore);
|
||||
const types = await bootstrap(store);
|
||||
const stringType = types["@string"];
|
||||
|
||||
// Create and store a simple string node
|
||||
@@ -673,9 +675,9 @@ describe("Suite 6: CLI Integration with Templates", () => {
|
||||
try {
|
||||
await runCli(["init"], tmpStore);
|
||||
|
||||
// Get @string type hash
|
||||
const { stdout: typesJson } = await runCli(["types"], tmpStore);
|
||||
const types = JSON.parse(typesJson);
|
||||
// Get @string type hash via bootstrap
|
||||
const store = createFsStore(tmpStore);
|
||||
const types = await bootstrap(store);
|
||||
const stringType = types["@string"];
|
||||
|
||||
// Create envelope and pipe to render
|
||||
|
||||
@@ -72,7 +72,7 @@ describe("Suite 1: Basic Rendering (No Nesting)", () => {
|
||||
|
||||
// Non-existent root node should throw
|
||||
expect(() => render(store, fakeHash)).toThrow(CasNodeNotFoundError);
|
||||
expect(() => render(store, fakeHash)).toThrow("Node not found");
|
||||
expect(() => render(store, fakeHash)).toThrow("CAS node not found");
|
||||
expect(() => render(store, fakeHash)).toThrow(fakeHash);
|
||||
});
|
||||
});
|
||||
@@ -795,9 +795,10 @@ describe("Suite 6: Schema Integration", () => {
|
||||
|
||||
test("6.5 Schema-less Node (Bootstrap Node)", async () => {
|
||||
const store = createMemoryStore();
|
||||
const metaHash = await bootstrap(store);
|
||||
const types = await bootstrap(store);
|
||||
const schemaHash = types["@schema"];
|
||||
|
||||
const output = render(store, metaHash);
|
||||
const output = render(store, schemaHash);
|
||||
|
||||
// Should render without recursive expansion
|
||||
expect(output).toBeTruthy();
|
||||
@@ -1068,7 +1069,7 @@ describe("Suite 10: Missing Root Hash Error Handling (Issue #53)", () => {
|
||||
CasNodeNotFoundError,
|
||||
);
|
||||
await expect(renderAsync(store, fakeHash)).rejects.toThrow(
|
||||
"Node not found",
|
||||
"CAS node not found",
|
||||
);
|
||||
await expect(renderAsync(store, fakeHash)).rejects.toThrow(fakeHash);
|
||||
});
|
||||
@@ -1078,7 +1079,7 @@ describe("Suite 10: Missing Root Hash Error Handling (Issue #53)", () => {
|
||||
const fakeHash = "ZZZZZZZZZZZZZ" as Hash;
|
||||
|
||||
expect(() => render(store, fakeHash)).toThrow(CasNodeNotFoundError);
|
||||
expect(() => render(store, fakeHash)).toThrow("Node not found");
|
||||
expect(() => render(store, fakeHash)).toThrow("CAS node not found");
|
||||
expect(() => render(store, fakeHash)).toThrow(fakeHash);
|
||||
});
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ export class CasNodeNotFoundError extends Error {
|
||||
public readonly hash: string,
|
||||
message?: string,
|
||||
) {
|
||||
super(message ?? `Node not found: ${hash}`);
|
||||
super(message ?? `CAS node not found: ${hash}`);
|
||||
this.name = "CasNodeNotFoundError";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user